>>Looks like the variable has to be initialized with something different than null to work, e.g.
>>
>>
>>LOCAL zz as Integer
>>zz=0
>>zz = null
>>=MESSAGEBOX(STR(zz,5))
>>
>>without zz=0 it gives the error.
>>
>>Interestingly, that
>>local zz as Character
>>zz=null
>>=messagebox(val(zz))
>>
>>works.
>>
>>By default, all variables are created with logical type, e.g.>>
>>=MESSAGEBOX(TYPE('zz')) returns L, that's why STR doesn't work.
>>
>
>Hi Naomi,
>STR and others native functions have bugs.
>
>The STR() C++'s inner logic it is:
>
>IF PARAMETER_DATATYPE<>CORRECT_DATATYPE
> ERROR ...
>ENDIF
>....
>
>
>A literal NULL is a 'X' DATATYPE and then these works:
>
>? STR(NULL,5)
>? STR(5,NULL)
>
>
>VAL() C++ logic it is correct:
>
>IF PARAMETER IS NULL
> RETURN CAST(NULL AS RETURN_DATATYPE)
>ENDIF
>...
>
>
>Fabio
Thanks a lot, Fabio, for the explanation.
If it's not broken, fix it until it is.
My Blog