Hi,
a couple of months ago a posted about a problem with using inline function calls and DateTime methods. I then was told that there might be a discrepancy between calling a function with the "Get MyFunction" command versus the "Move (MyFunction(params))". I didn't get any explanation to why though. Can't find anything in the documentation regarding this either.
Anyway, now I've encountered a new problem with inline function calls and I wanna know why VDF behaves this way, so I can avoid running into weird bugs in the future.
Here's a snippet that reproduces the bug:
Code:
//Using VDF 17.0
Class cProduceTheBug is a cObject
Procedure Construct_Object
Forward Send Construct_Object
End_Procedure
//The sKey will be "0" when called in an inline style.
Function Value String sKey Returns String
String sSomething
If (sKey = "0") Begin
Send Stop_Box "Key is 0!"
End
//Do stuff...
Function_Return sSomething
End_Function
End_Class
Procedure ProduceTheBug
Handle h
String sSomething
Get Create (RefClass(cProduceTheBug)) to h
//This works
Get Value of h "a key" to sSomething
//This does not work. It will show the stop box, e.g. the sKey is "0". It looks like the "a key" magically gets casted to an integer...
Move (Value(h, "a key")) to sSomething
End_Procedure
Send ProduceTheBug
Yes, I know that functions named Value are all over the VDF library and they usually take an integer parameter. But "Value" isn't an explicitly reserved method name and I should be allowed to name my functions however I want as long as the compiler is happy, right?
Although answers like "Just rename the function" and "You can't do that because Value is supposed to take an integer parameter" are intended to be helpful, I'm interested in a more low-level oriented answer.