@IdeasVacuum: I know you didn't want 'solutions' but instead a remedy. I provided the example for two reasons. The first was to show that it was possible to return another value and second, that this value had to be selected from the range of the output which produced its own problems (Danilo points these out).IdeasVacuum wrote:Thanks Demivec, in fact I do exactly that in another app - but solutions for Val() as it is now was not my interest when I started this post - it was about the design of the function. I've asked if a 3-wheeler car would be better with 4 wheels, but all the responders defend the 3-wheeler as if their life depends on it
I had neglected to extend the example to actually meet your needs by changing the range of the output
Code: Select all
Procedure.f myVal(sVal.s)
Protected Result.f = Val(sVal)
If Result = 0 And Not sVal
;Debug "empty string"
Result = NaN() ;magic value
EndIf
ProcedureReturn Result
EndProcedure
;Example 1
Debug myVal("0") ; 0
;Example 2
Debug myVal("") ; NaN float output
a = myVal("")
Debug a ; -2147483648 long output


