Scripting > UNICOM Intelligence Function Library > Conversion functions > CLong
 
CLong
Converts a value of any data type to a Long value.
Syntax
CLong(Val)
Parameters
Val
Type: None
Variant value to be converted.
(return)
Type: Long
Long value derived from Val.
Remarks
This function is similar to CLng in Visual Basic.
The result of the conversion depends on the data type of Val, as follows:
Boolean
The return value is 1 (True) or 0 (False).
Long
Val is returned unchanged.
Double
The return value is Val rounded to the nearest whole number except when the decimal places are exactly 5. In these cases, it rounds to the even integer. This means that of the two possible rounded values, the one that has an even number as the last significant digit is returned. For example, 14.5 is rounded to 14 rather than 15.
Date
The return value is the whole number part of the floating-point number used internally to represent the date.
Text
The string is parsed according to the locale to extract the value. An error occurs if the string does not contain a properly formatted integer.
Categorical
If the categorical value contains one category, the return value is the category value. Otherwise an error occurs.
Object
If the object has a default property, the value of that property is converted. Otherwise an error occurs.
NULL values
If Val is NULL, the return value is 0.
Examples
Data type
Value
Result
Boolean
False
0
Long
345
345
Double
567.8903
568
Double
3.5
4
Double
-3.5
-4
Double
2.5
2
Double
-2.5
-2
Double
2.50000001
3
Double
2.49999999
2
Date
14 April 2001
36995
Text
100.56
101
Categorical
{4,7}
Error
Categorical
{4}
4
For an example of using CLong in SQL queries, see I want to use the Data Model to access data, but I am used to SPSS-style data. Can you give me an overview?.
See also
CBoolean
Conversion functions