Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Confusion over NULL
Message
 
 
To
15/03/2007 08:49:22
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01203230
Message ID:
01203923
Views:
20
>>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)) && Should give an error too according to Help on VAL
>>
>>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
Previous
Reply
Map
View

Click here to load this message in the networking platform