TYPE( )
Topic group Related topics Example
Returns a character string that indicates a specified expression's data type.
Syntax
TYPE(<expC>)
<expC>
A character string containing the expression whose type to evaluate and return.
Description
Use TYPE( ) to determine the data type of an expression, including whether a variable is undefined.
TYPE( ) expects a character string containing the expression. This allows you to specify a variable name that may not exist. (If you were to use an actual expression with an undefined variable instead of putting the expression in a string, the expression would cause an error.) The <expC> may be any valid character expression, including a variable or a literal string representing the expression to evaluate.
TYPE( ) returns a character string containing a one- or two- letter code indicating the data type. The following table lists the values TYPE( ) returns.
Expression type |
TYPE( ) code |
Array object |
A |
DBF or Paradox binary field (BLOB) |
B |
Bookmark |
BM |
Character field or string value, Paradox alphanumeric field |
C |
Codeblock |
CB |
Date field or value, Paradox date field DateTime value |
D DT |
Float field, Paradox numeric or currency field |
F |
Function pointer |
FP |
OLE (general) field |
G |
Logical field or value |
L |
DBF or Paradox memo field |
M |
DBF numeric field or value |
N |
Object reference (other than Array) Time value |
O T |
Undefined variable, field, invalid expression, or null |
U |
Note that an object of class Array is a special case. Unlike other objects, its code is "A" (this is for backward compatibility with earlier versions of dBASE).
TYPE( ) cannot "see" variables declared as local or static. If there is a public or private variable hidden by a local or static variable of the same name, then TYPE( ) will return the code for that hidden variable. Otherwise, that variable and any expression using that variable is considered undefined.
Use TYPE( ) to detect whether a function, class, or method is loaded into memory. If so, TYPE( ) will return "FP" (for function pointer), as shown in the following IF statements, which detect if the named function is not loaded (this is done to determine if the specified function needs to be loaded):
if type( "myfunc" ) # "FP" // Function name
if type( "myclass::myclass" ) # "FP" // Class constructor name
if type( "myclass::mymethod" ) # "FP" // Method name