Data Type Functions
Contents
Analytica provides several functions for checking the data type of atoms (i.e., the items in an array). These are found in the Special library.
Function IsHandle
 IsHandle(X : Atom)
 IsHandle(X, local: true)
Tests whether the value in «X» is a handle. When «X» is arrayvalued, it tests whether each cell of the array contains a handle. The second form with local: true
tests whether a local variable «X» contains a handle. For details, see IsHandle.
Function IsNaN
 IsNaN(X: Atom)
NaN is a special value arising from indeterminate arithmetic operations indicating "Not A Number". NaN can arise from operations such as:
0/0
0*INF
INF  INF
IgnoreWarnings(Ln(1))
IgnoreWarnings(Sqrt(1))
The last two cases result in NaN since Analytica does not have internal support for complex numbers (see Ln, Sqrt and IgnoreWarnings). The other cases result because the result is indeterminate.
IsNaN(X) returns 1 (i.e., True) when «X» is the special value NaN, 0 (false) otherwise.
Function IsNumber
 IsNumber(X: Atom)
Returns True when «X» is a number, or any of the special values INF, INF, or NaN. It is also true when «X» is a complex number or a datetime number, since a datetime number is encoded as the number of days elapsed since the time origin. It returns false (zero) for text, even if the characters in the text could be parsed as a number.
Function IsRealNumber
 IsRealNumber(X: Atom)
Returns True when «X» is a real number or the special values INF or INF. It also returns true when «X» is a datetime number, since a datetime number is considered to be a numeric value  the number of days elapsed since the date origin. It differs from IsNumber in that it returns false (zero) for a complex or imaginary number or for the special value NaN.
Function IsDateTime
 IsDateTime(X: Atom)
Returns True when «X» is a datetime. A datetime is a special time of number in Analytica that encodes the number of days elapsed since the date origin, which is normally 1Jan1904, or 30Dec1899 if the "Use Excel Date Origin" preference is set. The fractional part of a datetime number represents a time. When printed, datetime numbers use the Date number format.
IsDateTime(X) is false for numbers other than those recognized as datetime numbers. It is also false for text values, even if the text itself appears to be a date or time.
Function IsReference
 IsReference(X)
Returns 1 (True) when «X» is a reference, 0 otherwise. When «X» is a reference, you can use the #X operator.
Function IsText
 IsText(X: Atom)
Returns 1 (True) when «X» is a textual string, 0 otherwise.
Comparison to Null
The expressions X = Null
or X <> Null
can be used to test whether «X» is the special system constant Null. Null results from certain operations where the value is not found, such as A[I = X]
when X
is not an element of I
(and warnings are ignored).
Null can also be detected using IsUndef(X).
Function IsUndef
 IsUndef(X: Atom)
Returns True if «X» is either of the two special system constants Undefined or Null. Undefined is a special system constant indicating that an attribute does not yet have a value, and also used to indicate that a value is not yet computed (e.g., that the (Mid) value or probValue attribute do not yet have a value), or that an optional parameter to a function was not specified. Null is a value returned by function evaluations indicating that a requested value is outofrange or does not exist.
The special value Null was introduced into Analytica 3.0. Prior to that, many functions returned Undefined when values did not exist, but were changed to return Null. To handle backward compatibility where the IsUndef function was being used to test for these values, IsUndef returns True in both cases.
Function IsNull
 IsNull(X)
Returns True if «X» is exactly Null. Returns False when «X» is another than Null. Does not array abstract, so if «X» is an array, even an array containing Null cells, it still returns atomic False. If you want to compare the cells of an array individually to Null, use x = Null
. If you want to test whether an attribute is set, use
 IsNull(attrib Of obj)
which will return False (0) if the attribute happens to contain an array with Null.
Note that IsNull is different from the other IsXXXX functions in that it does not array abstract.
Function IsNotSpecified
 IsNotSpecified(X: Atom)
Used within a userdefined function to determine whether an optional parameter has a value. If the optional parameter is not specified in the function call, and if the parameter has no default value, then IsNotSpecified returns true.
For example:
Function Fu1(A: Numeric; B: optional numeric)
Definition:
if IsNotSpecified(B) Then B := sqrt(A);
Normal(A*Time, B*sqrt(T))
Function TypeOf
 TypeOf(X: Atom; Shallow: optional boolean)
Returns the name of the atomic data type of «X» as a textual string. When TypeOf is applied to an array, the result is an array, where each cell contains the data type of the corresponding item in the original array. When «shallow» is true, a less detailed type description is given. In many cases, TypeOf exposes details of the internal representation being used; hence, it is preferable to make use of the IsXXX() functions when possible.
When X is:

TypeOf(X) returns:

TypeOf(X, shallow: true) returns:


A real number stored internally in IEEE 754 double binary float format  "Number"  "Number" 
An integer value stored internally as a 64bit signed integer  "Integer"  "Number" 
A realvalue stored internally in a fixedpoint real number format  "FixedPoint"  "Number" 
A date/time numeric value  "DateTime"  "DateTime" 
A complex (imaginary) number  "ComplexNumber"  "ComplexNumber" 
A textual value  "Text"  "Text" 
Null  "Null"  "Null" 
A Linear optimization Program (returned by DefineOptimization)  "LP"  "Custom" 
A Quadratic optimization Program with linear constraints (returned by DefineOptimization)  "QP"  "Custom" 
A Quadratically Constrained optimization Program (returned by DefineOptimization)  "QCP"  "Custom" 
A NonLinear optimization Program (returned by DefineOptimization)  "NLP"  "Custom" 
An ODBC Record Set object  "RecordSet"  "Custom" 
A parsed expression where the outermost operation is an operator  "Expression"  "Expression" 
A parsed expression where the outermost operation is a function call  "FunctionCall"  "FunctionCall" 
A binary blob of data, e.g., from a Pict attribute  "Data"  "Data" 
A Handle to an object with the class «className»  "«className»", one of:
"Decision" 
"Object" 
A Reference  "Reference"  "Reference" 
The data from an input or output attribute  "ObjectSet"  "ObjectSet" 
The parameter to TypeOf is evaluated. So, if you apply this to a function parameter or local variable, the type of the value is returned, even if the parameter is declared as an index or variable type. For example:
Function F1(A: Variable) := TypeOf(A)
When you call F1(Ch1)
, the type of each atom in the value of Ch1
is returned  not the class of Ch1
. If you wanted the class of the object, it would be easiest to use:
Function F2(A: Variable) := class of A
which would return "Chance" when call F2(Ch1)
.
Enable comment autorefresher