Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.NULL. or null 1

Status
Not open for further replies.

AlastairP

Technical User
Feb 8, 2011
286
0
16
AU
What is the difference between .NULL. and null when intending to add null to a property

For instance should I use

Code:
store .NULL. to obj.parameter

or

Code:
store null to obj.parameter
 
There is no difference.

Originally, certain keywords were required to be surrounded by dots, but at some point that requirement went away. NULL is one example of that. Others include AND, OR and NOT.

So just use whichever form you prefer.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks Mike.
Have a good weekend

Alastair
 
Alastair,

Bear in mind that the Properties window treats null and .null. differently: a property initialized as .null. is set to .NULL., whereas a property initialized as null or NULL or Null is set to a string ("null", "NULL", or "Null", ...). To use the dotless notation, you have to prepend the property value with an equal sign (that is, = null).
 
Good point, atlopes.

To round this up: VFP still needs dots for .T. and .F., obviously, while you can use null in code, t and f would be interpreted as variable or workarea or field names, especially f. As null was introduced as a synonym for .NULL. they didn't made the same step for true and false, though.

Because of these details I would opt to still write .NULL. anywhere you mean that boolean special value, except that the ISNULL() function can't be addressed as IS.NULL.(), of course.

I don't apply that rule of thumb to still use the dots with .AND. and .OR. and use the normal AND/OR operators, even though you can use AND and OR as variable names! While the dots around them make it expressively boolean operators and not names of variables, workareas or anything else, there's no problem to identify what's meant. Even though you can have a variable AND=42, the code IF foo=bar AND AND=42 still will work out fine and there is no way the AND in the middle of the IF expression is mistaken for the variable or the variable after it is mistaken for the boolean AND operator. It's the context/semantics that make it clear what each AND in that IF expression means, no need for dots. I'm sure someone can come up with some example where that would matter, but another rule of thumb therefore is to not use keywords as names of anything. Simply to not confuse yourself when reading the code.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top