Returning from a function

Blitz3D Forums/Blitz3D Programming/Returning from a function

Aries(Posted 2007) [#1]
hi, i was just wondering if anybody knew why i cant seem to be able to return a decimal number from a function, the number is always rounded up or down.

small example:

Graphics 640,480
SetBuffer BackBuffer()

While Not KeyDown(1)
Cls

If KeyDown(200) Then x# = x# + 0.01

a# = find_x(x#)

Text 0,0,"a = " +a#
Text 0,20,"x = " +x#

Flip
Wend
End


Function find_x(x#)
Return x#
End Function

both numbers should be the same, but there not?

cheers.


_33(Posted 2007) [#2]
Function find_x#(x#)
   Return x#
End Function



degac(Posted 2007) [#3]
You need to specify what 'type' of data is returned by the function.
In this case you need to specify
Function Find_x#(x#); <------- Note the # symbol for FLOAT value (x# is a float)
Return x#
End Function



Aries(Posted 2007) [#4]
oh god, the solution was so simple haha, thanks alot.