Language Elements and Reference:xpplrm

Operations using the value NIL Foundation

The data type NIL includes only one value: NIL. This value can be used to perform "comparison" and "assignment" operations. Other operations are not allowed and lead to runtime errors. The following table contains the valid operators for NIL:

Operators for NIL
Operator Description
== Comparison: equal
= Comparison: equal
!= <> # Comparison: not equal
= Assignment
:= Inline assignment

The comparison of two values or variables for equality or inequality generally requires that both values have the same data type. An exception is the data type NIL, whose value ( NIL) can be compared with any other data type. If NIL is used as an operand for either of the equality operators = or ==, the operation only returns the value .T. if the other operand also contains the value NIL.

cString := "Xbase++" 
nNumber := 2 
lLogic  := .T. 
dDate   := Date() 
uUndef  := NIL 

? cString == NIL                // result: .F. 
? nNumber == NIL                // result: .F. 
? lLogic  == NIL                // result: .F. 
? dDate   == NIL                // result: .F. 
? uUndef  == NIL                // result: .T. 

Inequality comparisons are similar. Calculations and manipulations can not be performed using NIL and there are no functions to process or change the value NIL. There are only three functions available and all test a variable with the value NIL.

Functions for NIL
Function Description
Empty() Tests whether a value is NIL (or another empty value)
Type() Determines data type via macro operator
Valtype() Determines data type

? uUndef := NIL                 // result: NIL 
? Empty(uUndef)                 // result: .T. 
? TYPE ("NIL")                  // result: U 
? Valtype(uUndef)               // result: U 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.