Language Elements and Reference:xpplrm

Constants Foundation

Constants are written into the program code and are treated as a value (not as a variable) by the compiler. These are also sometimes called literals. The Xbase++ compiler distinguishes constants of four different data types as illustrated in the following program code:

xVariable= NIL                 // Undetermined constant (nothing) 

nNumber1 = 1                   // Numeric constant (integer) 
nNumber2 = 3.1415926           //   -"-    (floating point number) 

lTrue    = .T.                 // Logical constant (true) 
lFalse   = .F.                 //   -"-            (false) 

cString1 = "Character string"  // Character strings-constant 
cString2 = 'Character string'  //   -"- 
cString3 = [Character string]  //   -"- 

The value NIL is a preset constant which contains no value (nothing). Numeric constants are identified by digits with an optional decimal point and signed prefix (+/-) (if they are necessary). Logical constants include the two logical values .T. (true) and .F. (false). Character constants are strings which can be delimited using one of three different delimiting characters: the single quotation mark, double quotation marks and brackets. For program code to be readable, character constants should always be enclosed in quotation marks (single or double), since brackets also identify array elements.

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.