user manual
135
CLEM Language Reference
Conversion Functions
Conversion functions allo w you to construct n ew fields and convert the storage type of existing
files. For example, you can form new strings by joining strings together or by taking strings apart.
To join two st
rings, use the operator ><. For exa mple, if the field Site has the v alue "BRAMLEY",
then "xx" >< Site re turns "xxBRAMLEY". The result of >< is always a string, even if the arguments are
not strings. Th us, if field V1 is 3 a nd field V2 is 5, then V1 >< V2 returns "35" (a string, not a number).
Conversion f
unctions (and any other functions that require a specific ty pe of input, such as a
date or time value) depend on the current formats specified in the Str eam Options dialog box.
For example, if you want to convert a string field with values Jan 2003, Feb 2003, and so on,
select the ma
tching date format MON YYYY as the default date format for the stream. For more
informa tion, see the topic Setting general options for streams in Chapter 5 on p. 55.
Function
Result
Descriptio
n
ITEM1 >< ITEM2
String
Concatenates values for two fields and retu rns the resulting
string as ITEM1ITEM2.
to_integer(ITEM)
Integer
Converts the storage of the specified field to an int eger.
to_real(ITEM)
Real Converts t
he storage of the specified field to a real.
to_number(ITEM)
Number Converts the storage of the specified field to a number.
to_string(ITEM)
String
Converts the storage of the specified field to a string.
to_time(ITEM)
Time
Converts the storage of the specified field to a time.
to_date(ITEM)
Date
Converts the storage of the specified field to a date.
to_timestamp(ITEM)
Timestamp
Converts the storage of the specified field to a timestamp.
to_datetime(ITEM)
Datetime
Converts the storage of the specified field to a date, tim e,
or timestamp valu e.
datetime_date(ITEM)
Date
Returns the date value for a number, string, or timestamp.
Note this is the onl y fu nction that allows you to convert a
number (in seconds) back to a date. If ITEM is a string,
creates a date by parsing a string in the current date format.
The date format specified in the stream properties dialog
box must be correct for this function to be su ccessful. If
ITEM is a number, it is interpreted as a number o f seconds
since the base date (or epoch). Fractions of a day are
truncated. If ITEM is a timestamp , the d at e part of the
timestamp is returned. If ITEM is a date, it i s returned
unchanged.
Comparison Functions
Compa r is on functions are used to compare field values to each other or to a specified string. Fo r
example, you ca n check strings for e qualit y using =. An example of string equality ver ification
is: Class = "class 1".
For purposes of numeric comparison, greater means closer to positive infinity, and lesser
means closer to negative infinity. That is, all negative numbers are less than any positive number.
Function
Result
Description
count_equal(ITEM1, LIST)
Integer
Returns the n umber of values from a list of fields that
are equal to ITEM1 or null if ITEM1 is null. For more
information, see the topic Summarizing Multi ple F i el ds in
Chapter 7 on p. 115.