How-to Guides‎ > ‎Some crib sheets‎ > ‎

CL crib sheet


CL Declarations

attach a set of methods to a database table

script <tablename>
    {method-declarations}
end script

define a CL class (when using the CLC executable)

class <classname> [is <base-clasname>]
    {attribute-declarations}
    {method-declarations}
end class

define a method to be triggered when an object is created in a class/table:

on  create
    <method-body>
end create
Note that the on create trigger for a base class is run first, then those for the class derivation tree in order

define a method to be triggered when an object is deleted from a class/table:

on  delete
    <method-body>
end delete
Note that all the on delete triggers for the class derivation tree are run in order, ending with that for the base class

define a method to be triggered when an attribute of an object is changed in a class/table

on  set <attribute-name>
    <method-body>
end set <attribute-name>

other methods

You can also define functions (which have global scope if defined outside a script... end script or class... end class grouping), procedures (which can have arguments, but do not return a result), and global constants (which can truly be constants, or their values can be defined by a function that is run when the database server is started, and thus can depend on resource settings or the contents of the database at the time the server started).

Virtual methods

All methods are virtual, other than the on create and on delete triggers which are applied cumulatively (as described above).

CL statements, in alphabetical order

add <numeric_expr> to <variable>
assert <condition>
beep [<count>]
commit <object> {, <object>}
create <class-name> [<initialisation>] into <variable>
debug <expression> [at <severity>] [with <code>]
delay <delaytime>
delete <variable>
divide <variable> by <number>
do <event-name> [to <target>]
emit <event-name> [to <target>] [priority <pri>]
exit
exit repeat
fill <attribute> with <query> [(<parameters>)] [into <name> {, <name>}]  [as <type-name>] [from <data-service>]
forget <variable>
if <condition> then <statement>
if <condition> then
     <statement-list>
[{else if <condition> then
     <statement-list>}]
[else
     <statement-list>]
end if
insert <object> into <array> [at <position>]
link <attribute> with <query> <parameters> [into <name> {, <name>}] [insert <insert-procedure>] [update <update-procedure>] [delete <delete-procedure>] [as <type-name>] [from <data-service>] [emit <event-name>] [get <recordct>] [sleep|delay <delaytime>]
locate <class-name> [<restriction>] into <variable>
multiply <variable> by <number>
next repeat
quit
remove <object> from <array>
repeat for <count>
    <statement-list>
end repeat
repeat foreach <variable> in <array>
    <statement-list>
end repeat
repeat forever
    <statement-list>
end repeat
repeat until <condition>
    <statement-list>
end repeat
repeat while <condition>
    <statement-list>
end repeat
repeat with <variable>=<expr> to <expr>
    <statement-list>
end repeat
return <expression>
rollback <object> {, <object> }
send <procedure-name> [( <arguments> )] [to  <object>] [threadpriority <pri>]
set <variable> to <expression> [as <type-name>]
sleep < delaytime >
sql <sql-statement> [to <data-service>]
start transaction on <object> {, <object> }
subtract <number> from <variable>
switch <integer-expr>
    { default | case <integer_expr>  
       <statement-list>  
    end case }
end switch
throw <object>
try
    <statement-list>
    { catch <exception-class> into <variable>
      <catch-statement-list> }
end try
unlink <attribute>

CL functions

Arithmetic functions

Abs Real abs (Real) Returns the absolute value of a number.
Acos Real acos (Real) Returns the principal value of the arc cosine of the parameter.
Asin Real asin (Real) Returns the principal value of the arc sine of the parameter.
Atan Real atan (Real) Returns the principal value of the arc tangent of the parameter.
Atan2 Real atan2 (Real, Real) Returns the principal value of the arc tangent using the signs of both parameters to determine the quadrant of the return value.
Average Real average (Real, ...) Returns the average (mean) of its parameters.
Cos Real cos (Real) Returns the cosine of the parameter.
Cosh Real cosh (Real) Returns the hyperbolic cosine of the parameter.
Exp Real Exp (Real value) Returns the exponential of the value.
Max Real max (Real, ...) Returns the maximum value of its parameters.
Min Real min (Real, ...) Returns the minimum value of its parameters.
NotANumber Boolean notANumber (Real) Returns a Boolean depending on whether the parameter is a valid Real number.
Round Integer round (Real) Rounds a Real to an Integer.
Sin Real sin (Real) Returns the sine of the parameter.
Sinh Real sinh (Real) Returns the hyperbolic sine of the parameter.
Sqrt Real sqrt (Real) Returns the square root of a number.
Sum Real sum (Real, ...) Returns the sum of all of its parameters.
Tan Real tan (Real) Returns the tangent of the parameter.
Tanh Real tanh (Real) Computes the hyperbolic tangent of the parameter.
Truncate Integer truncate (Real) Truncates a Real to an Integer.

DateTime functions

Add_months DateTime add_months (DateTime, Integer) Adds the interval of months specified to the given DateTime value.
Add_years DateTime add_years (DateTime, Integer) Adds an interval of years to the given DateTime value.
Date DateTime date (String) Returns a DateTime value from the given String.
Datetime DateTime datetime (String) Returns a DateTime value from the given String.
Datetimef DateTime datetimef (String, Format) Returns a DateTime value from the given String, in the supplied Format.
Days DateTime days (Integer) Returns a DateTime value specifying an interval of days.
Get_date String get_date (DateTime) Returns a String value representing the date in the given DateTime value.
Get_datetime String get_datetime (DateTime) Returns a String value representing the datetime in the given DateTime value, using the default format.
Get_datetimef String get_datetimef (DateTime, Format) Returns a String value representing the datetime in the given DateTime value using the specified Format.
Get_time String get_time (DateTime) Returns a String value representing the time in the given DateTime value.
Hours DateTime hours (Integer) Returns a DateTime value specifying an interval of hours.
IsValidDateTime Boolean is ValidDateTime (DateTime) Indicates whether a DateTime is valid.
LastDay DateTime lastDay (DateTime) Returns as a DateTime value the last day of the month in the given DateTime value.
LocalTime DateTime localTime (DateTime) Converts from standard time to local time.
Microseconds DateTime microseconds (Integer) Returns a DateTime value specifying an interval of microseconds.
Milliseconds DateTime milliseconds (Integer) Returns a DateTime value specifying an interval of milliseconds.
Minutes DateTime minutes (Integer) Returns a DateTime value specifying an interval of minutes.
Now DateTime now () Returns the current date and time.
Seconds DateTime seconds (Integer) Returns a DateTime value specifying an interval of seconds.
StandardTime DateTime standardTime (DateTime) Converts from local time to standard time.
The_day Integer the_day (DateTime) Retrieves the days from a DateTime value.
The_hour Integer the_hour (DateTime) Retrieves the hours from a DateTime value.
The_microsecond Integer the_microsecond (DateTime) Retrieves the microseconds from a DateTime value.
The_millisecond Integer the_millisecond (DateTime) Retrieves the milliseconds from a DateTime value.
The_minute Integer the_minute (DateTime) Retrieves the minutes from a DateTime value.
The_month Integer the_month (DateTime) Retrieves the months from a DateTime value.
The_second Integer the_second (DateTime) Retrieves the seconds from a DateTime value.
The_weekday Integer the_weekday (DateTime) Returns a numeric value for the day of the week.
The_year Integer the_year (DateTime) Retrieve the years from a DateTime value.
Time DateTime time (String) Returns a DateTime value specifying the given time.
To_days Integer to_days (DateTime) Calculates the number of days between a DateTime value and the beginning of time.
To_hours Integer to_hours (DateTime) Calculates the number of hours between a DateTime value and the beginning of time.
To_minutes Integer to_minutes (DateTime) Calculates the number of minutes between a DateTime value and the beginning of time.
To_months Integer to_months (DateTime) Calculates the number of months between a DateTime value and the beginning of time.
To_microSeconds Real to_microSeconds (DateTime) Converts a date-time value to microseconds.
To_seconds Real to_seconds (DateTime) Converts a date-time value to seconds.
Today DateTime today () Returns today's date.

Character and string functions

AsciiToChar String asciiToChar (Integer) Returns the character of a given ASCII or Unicode value.
CharToAscii Integer charToAscii (String) Returns the ASCII or Unicode value of the first character of the String
CharToNum Integer charToNum (String) Converts an integer value held in a String to an Integer.
LowerCase String lowerCase (String) Converts a String to lower-case characters.
NumberOfChars Integer numberOfChars (String) Returns the number of characters in a String.
NumberOfItems Integer numberOfItems (String) Returns the number of items in a String.
NumberOfLines Integer numberOfLines (String) Returns the number of lines in a String.
NumberOfWords Integer numberOfWords (String) Returns the number of words in a String.
UpperCase String upperCase (String) Converts a String to upper-case characters.

Binary functions

BinaryToHexString String binaryToHexString (Binary) Returns a hexadecimal representation of a binary.
FindBinInBinary Integer findBinInBinary (Binary haystack, Binary needle) Finds a binary needle in a binary haystack.
FindFloat32InBinary Integer findFloat32InBinary (Binary, Real) Finds a 32 bit floating point value in a binary.
FindIntInBinary Integer findIntInBinary (Binary, Integer) Finds a 32 bit integer value in a binary.
FindInt8InBinary Integer findInt8InBinary (Binary, Integer) Finds an 8 bit integer value in a binary.
FindInt16InBinary Integer findInt16InBinary (Binary, Integer) Finds a 16 bit integer value in a binary.
FindInt64InBinary Integer findInt64InBinary (Binary, Integer) Finds a 64 bit integer value in a binary.
FindRealInBinary Integer findRealInBinary (Binary, Real) Finds a 64 bit floating point value in a binary.
GetBinInBinary Binary getBinInBinary (Binary, Integer start, Integer length) Extracts a binary value from a binary value.
GetBitInBinary Boolean getBitInBinary (Binary, Integer bitnumber) Returns the value of a bit in the binary value.
GetDateTimeInBinary DateTime GetDateTimeInBinary (Binary, Integer fieldnumber) Returns the value of a date-time in a binary value.
GetFloat32InBinary Real getFloat32InBinary (Binary, Integer fieldnumber) Returns the value of a 32 bit floating point field in the binary value.
GetIntInBinary Integer getIntInBinary (Binary, Integer fieldnumber) Returns the value of a 32 bit integer field in the binary value.
GetInt8InBinary Integer getInt8InBinary (Binary, Integer fieldnumber) Returns the value of an 8 bit integer field in the binary value.
GetInt16InBinary Integer getInt16InBinary (Binary, Integer fieldnumber) Returns the value of a 16 bit integer field in the binary value.
GetInt64InBinary Integer getInt64InBinary (Binary, Integer fieldnumber) Returns the value of a 64 bit integer field in the binary value.
GetRealInBinary Real getRealInBinary (Binary, Integer fieldnumber) Returns the value of a 64 bit floating point field in the binary value.
GetStrInBinary String getStrInBinary (Binary, Integer start, Integer length) Extracts a string from a binary value.
GetStrAsUCS2InBinary String getStrAsUCS2InBinary (Binary, Integer start, Integer length) Extracts a string encoded in UCS-2 format from a binary value.
HexStringToBinary Binary hexStringToBinary (String) Returns a binary value from a string of hexadecimal digits.
NumberOfBytes Integer numberOfBytes (Binary) Returns the number of bytes in Binary value.
SetBinInBinary Binary setBinInBinary (Binary base, Integer start, Binary patch) Returns a binary which has been partially overwritten with another binary.
SetBitInBinary Binary setBitInBinary (Binary base, Integer bitnum, Boolean bitvalue) Returns a binary which has been altered to have a specific bit set.
SetFloat32InBinary Binary setFloat32InBinary (Binary base, Integer fieldnum, Real value) Returns a binary with a 32 bit floating point value stored in a specified field.
SetIntInBinary Binary setIntInBinary (Binary base, Integer fieldnum, Integer value) Returns a binary with a 32 bit integer value stored in a specified field.
SetInt8InBinary Binary setInt8InBinary (Binary base, Integer fieldnum, Integer value) Returns a binary with an 8 bit integer value stored in a specified field.
SetInt16InBinary Binary setInt16InBinary (Binary base, Integer fieldnum, Integer value) Returns a binary with a 16 bit integer value stored in a specified field.
SetInt64InBinary Binary setInt64InBinary (Binary base, Integer fieldnum, Integer value) Returns a binary with a 64 bit integer value stored in a specified field.
SetRealInBinary Binary setRealInBinary (Binary base, Integer fieldnum, Real value) Returns a binary with a 64 bit floating point value stored in a specified field.
SetStrInBinary Binary setStrInBinary (Binary base, Integer start, String patch, Boolean includeNull) Returns a binary which has been partially overwritten with a string.
SetStrAsUCS2InBinary Binary setStrAsUCS2InBinary (Binary base, Integer start, String patch, Boolean includeNull) Returns a binary which has been partially overwritten with a string encoded in UCS-2 format.

Bit functions

BitAnd Integer bitAnd (Integer, ...) Returns the bit-wise AND of its parameters.
BitGet Integer bitGet (Integer value, Integer n) Returns the value of a specified bit.
BitOr Integer bitOr (Integer, ...) Returns the bit-wise OR of its parameters.
BitSet Integer bitSet (Integer, Integer) Returns value with a specified bit set.
BitShift Integer bitShift (Integer, Integer) Returns a value shifted left or right.
BitShiftLeft Integer bitShiftLeft (Integer, Integer) Returns a value shifted left by a specified number of bits.
BitShiftRight Integer bitShiftRight (Integer, Integer) Returns a value shifted right by a specified number of bits.
BitTest Boolean bitTest (Integer, Integer) Returns whether a specified bit is set.
BitUnset Integer bitUnset (Integer, Integer) Returns a value with a specified bit cleared.
BitXOr Integer bitXOr (Integer, ...) Returns the bit-wise XOR of its parameters.

Communication functions

GetHostName String getHostName (integer address) Converts an integer IP address in host byte order to a string containing the name it is known by locally.
GetIPAddress Integer getIPAddress (String address) Converts a string containing a machine name or address in numbers-and-dots notation to an integer in host byte order.
GetIPFromDataService Integer getIPFromDataService (String dataService) Extracts the host machine from the Polyhedra data_service resource supplied and returns the machine's IP address in host byte order.
GetLocalIPAddress Integer getLocalIPAddress () Returns an integer representation of the local IP address in host byte order.
GetMachineAddress String getMachineAddress (String name) Returns the IP address for a specified machine name.
GetMachineName String getMachineName (String address) Returns the machine name for a specified IP address.
GetPortNumber Integer getPortNumber (String address) Converts a string containing a port identifier to the corresponding number of the local port in host byte order.

Miscellaneous functions

DoSql String doSql (String sql) Returns a null string.
EncryptPassword String encryptPassword (String password) Returns the encrypted value of password.
GetArraySize Integer getArraySize (Array of Object) Returns the number of elements in an Array.
GetCaller Object getCaller () Returns the previous value of me for the current thread.
GetEnv String getEnv (String var_name) Returns the value of the environment variable var_name.
GetPriority Integer getPriority () Returns the priority of the currently executing thread.
GetResource String getResource (String) Returns value of a resource defined for the Polyhedra module.
GetUser String getUser (String) Returns the name of the user that initiated the current transaction .
GetVersion String getVersion (String) Returns a description of the component and its version.
Random Integer random () Returns a random number.
Seed Integer seed (Integer) Seeds the random number generator. Returns the value of the argument passed to the function.
SetPriority Integer setPriority (Integer) Sets the priority of the currently executing thread.

CL reserved Words

These are listed on a separate page (along with Polyhedra SQL reserved words, and other words that it might be sensible to avoid in your applications).