QB64 Phoenix Edition
FUNCTION Event(x AS DOUBLE) AS DOUBLE - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: FUNCTION Event(x AS DOUBLE) AS DOUBLE (/showthread.php?tid=2408)



FUNCTION Event(x AS DOUBLE) AS DOUBLE - Dimster - 01-26-2024

Before creating a function I normally would Dimension x as Double BEFORE I actually call the function. For example

Dim x as Double
...code..
...code..

x = Event
...
Function Event(x)
...code...
End Function

But, dimensioning on an "as needed basis" or "on the run" what is the correct syntax

Function Event (x as Double) as Double or Function Event(x) as Double or Function Event (x as Double)??

It's hard to give up on the old ways, if they worked, to learn a new more efficient way. (by efficient I mean to reduce all those Dim Shared variables I have at the beginning of my code to only creating them when they are actually called for service.


RE: FUNCTION Event(x AS DOUBLE) AS DOUBLE - Kernelpanic - 01-26-2024

(01-26-2024, 04:17 PM)Dimster Wrote: . . .
Function Event (x as Double) as Double or Function Event(x) as Double or Function Event (x as Double)??

It's hard to give up on the old ways, if they worked, to learn a new more efficient way. (by efficient I mean to reduce all those Dim Shared variables I have at the beginning of my code to only creating them when they are actually called for service.
I don't really understand what you actually want. . .  Huh

Code: (Select All)

'Declaration
Declare Function Endpreis(kaufpreis, mehrwertSteuer As Double) As Double

. . . Code

'Definition
Function Endpreis (kaufpreis, mehrwertSteuer As Double)

  Dim As Double gesamtpreis

  gesamtpreis = kaufpreis + ((kaufpreis * mehrwertSteuer) / 100)
  Endpreis = gesamtpreis
End Function



RE: FUNCTION Event(x AS DOUBLE) AS DOUBLE - SMcNeill - 01-26-2024

Are you looking for:

FUNCTION Event# (x AS DOUBLE)

The # after the name Event denotes it as returning a double value back to us.  Wink


RE: FUNCTION Event(x AS DOUBLE) AS DOUBLE - TerryRitchie - 01-26-2024

Code: (Select All)
PRINT Event

FUNCTION Event# (x AS DOUBLE)

    'code here
    Event = 1000

END FUNCTION
.
You can't declare a function AS DOUBLE, you must instead use the type identifier as shown above.

Update: Steve beat me to it my mere seconds Smile


RE: FUNCTION Event(x AS DOUBLE) AS DOUBLE - Dimster - 01-26-2024

That where I've  missed the boat - the correct syntax is 
FUNCTION Event#(x as double)
Thank you