[Gambas-user] Function doing unexpected things...

sbungay sbungay at ...981...
Thu Jul 20 04:34:37 CEST 2006


    How to explain this without writing tons of code... hmmmmm.. here goes.
   I have a class which contains 3 public variables of type float.
   The class gets instantiated.
   One of the items within the class is named "subtotal" and it's value 
is derived by summing up the items in one column of a grid. To do this I 
wanted to use a function which returned type Float. So (keeping code 
here to a minimum) the whole mess looks kind of like this...

ClassName.SubTotal = ComputeSubTotal(GridName,GridName.Column)

Private Function ComputeSubTotal (SourceGrid AS GridView, Col as 
Integer) AS Float
Dim SubTotal AS Float
.
.
.
Logic to sum the column into "SubTotal" goes here
.
.
.
Return SubTotal
End

   Gives me the error

"Expected Float, got Function"

   I expected the assignment to take the return value of the function 
not the function itself... is this a bug or am I doing something wrong? 
I can work around it using a SUB but IMHO it is more elegant to use a 
function.

P.S.
   Haven't used GAMBAS for over a year, just downloaded the latest 
version and compiled it... it's looking very good Benoit. I like the new 
editor.




More information about the User mailing list