Appendix A Built-In Functions for ADL

A.2 Function Descriptions

A.2.1 Input/Output

echo (any argument)

Effects: prints a human-readable representation of argument to standard output.

Returns: argument.

read ()

Effects: reads a string up to white-space from standard input.

Returns: the string that was read.

die (string message)

Effects: prints the contents of message to standard error, then exits with exit code

Returns: die does not return

A.2.2 Time and Date

localTime()

Returns: A time value whose hours, minutes, seconds, and milliseconds are set to the current local time.Platforms that cannot provide a given level of granularity should return 0 for that part of the time. For instance, if a machine cannot provide milliseconds, localTime may return the current time with milliseconds set to 0.

Note: AthenaMuse2 relies on the system's idea of the current local time for this function. If you are not happy with the value returned, please check that the time is set properly on your machine.

localDate()

Returns: A list containing four integer elements:

1. day of week, 1 - 7, 1 == Sunday, etc.

2. day of month, 1 - 31

3. month of year, 1 - 12

4. year, 1900 -

Note: AthenaMuse2 relies on the system's idea of the current date for this function. If you are not happy with the value returned, please check that the date is set properly on your machine.

A.2.3 Conversion

toBoolean(any source)

Requires: a boolean, a string containing a "TRUE" or "FALSE" (any capitalization), an integer, a real, or a time.

Effects:. ERtype error if the type cannot reasonably be converted to a boolean.

Returns: a boolean representation of the value in source.

toInteger(any source)

Requires: an integer, a string containing an integer, a real that is smaller than the maximum size of an integer, a boolean, or a time (converts to number of milliseconds).

Effects: ERsemantic error if the value in source is too large for an integer.ERtype error if the value in source cannot reasonably be converted to an integer.

Returns: an integer representation of the value in source.

toInterval(any source)

Requires: An interval, a string containing an interval constant, or a list of the format: {{boolean,integer/real},{boolean,integer/real}}.

Effects: ERtype error if the value in source cannot reasonably be converted to an interval.

Returns: the interval representation of the value in source.

toTime(any source)

Requires: A time, an integer (milliseconds), a real (rounded to integer milliseconds), a string, or a list with one to four integer elements (representing the least significant parts of the time, i.e. 2 elements implies seconds and milliseconds).

Effects: ERtype error if the value in source cannot reasonably be converted to a time.

Returns: the time representation of the value in source.

toList(any source)

Requires: A list, a string containing a list with constant elements, or an interval.

Effects: ERtype if the value in source cannot reasonably be converted to a list.

Returns: the list representation of the value in source.

toReal(any source)

Requires: A real, an integer, a boolean, or a string representing a constant real in the same format as that recognized by the parser

Effects: ERtype if the value in source cannot reasonably be converted to a real.

Returns: A real number representing the value in source.

toString(any source)

Returns: A string representation of source. If source is a handle this call produces a fatal error.

A.2.4 Type Query

Returns: TRUE if value is of the given type, FALSE if not.

getType(any value)

Returns: The vtype of the argument value.

canConvert(string source, vtype conversionType)

Returns: TRUE if the source can be converted to conversionType, FALSE if not. Put another way, canConvert returns TRUE if the appropriate conversion built-in (toBoolean, toInteger, etc.) for conversionType succeeds when given source as an argument.

A.2.5 Sequences (lists and strings)

Lists

at(integer index, sequence source)

Returns: If source is a list, the item at index is returned. If source is a string, a one character string containing the character at index is returned. The index is counted from 1, not 0.

Notes: If index exceeds the length of source, an ERsemantic error is generated. This behavior may change.

first(sequence source)

Returns: The first element of the list if source is a list or the first character of it is a string. If source is empty, an empty sequence of the same type as source (list or string) is returned.

rest(sequence source)

Returns: A sequence of the same type (list or string) containing all but the first element in source. If the sequence is empty or only contains a single element or character, the returned sequence will be empty.

isEmpty(sequence test)

Returns: TRUE if test contains no items (list) or characters (string), FALSE otherwise.

length(sequence source)

Returns: The number of elements (list) or characters (string) in source.

extract(sequence source,integer start,integer length)

Returns: A sequence containing the elements of source with indices from start to start+length-1. Sequence indices start at 1, not 0.

Notes: If an attempt is made to extract beyond the end of a sequence, a shorter sequence will be returned containing only those items from start to the end of the sequence.

find(any key, sequence source)

Returns: If source and key are strings, returns index of first character of first occurrence of key in source, or 0 if key is not found in source (since indices in sequences start with 1). If source is a string, but key is not, an ERsemantic error is generated. If source is a list, returns index of first member of source found to be equal to key, or 0 if no match is found.

Notes: lists are not searched recursively, only top level members are compared, and no type conversion is performed, i.e. 1.0 != 1.

Strings

split(string source, string delim)

Returns: the list of substrings from source that remains after every occurrence of delim is deleted from it. If two instances of delim occur immediately adjacent to each other or if source starts or ends with an occurrence of delim, then an empty string is inserted into the list at the appropriate position.

isAlpha(string source)

Returns: TRUE if all the characters in the source string are one of [A-Z, a-z]

toUpper(string source)

Returns: a string identical to source except that all lowercase alphabetic characters will have been changed to uppercase.

Example: toUpper("teSt sTriNG!") returns "TEST STRING!"

toLower(string source)

Returns: a string identical to source except that all uppercase alphabetic characters will have been changed to lowercase.

A.2.6 Mathematical

The mathematical built-ins that follow can produce six categories of errors:

By default, DOMAIN and SING errors are treated as fatal, and all others are ignored. The developer may change this behavior by sending a 'SetFatalErrors message to theApp. Please see _ for further information.

random(interval range)

Returns: A random number in range. If both limits of range are integers, an integer will be returned; otherwise a real will be returned.

sqrt(number val)

Returns: The nonnegative square root of val expressed as a real. A DOMAIN error occurs if val is negative.

pow(number base, number exp)

Returns: base raised to the power exp expressed as a real. exp may be a real if base is nonnegative. A DOMAIN error occurs if base is negative and exp is not an integral value, and it may occur when base is 0 and exp is less than or equal to 0. This built-in may also generate OVERFLOW or UNDERFLOW errors.

exp(number val)

Returns: The exponential function of val, INDEXES (not implemented) , expressed as a real. An OVERFLOW or UNDERFLOW error may occur.

log(number val)

Returns: The natural logarithm of val expressed as a real. A DOMAIN error will occur if val<0.0 and a SING error if val==0.

log10(number val)

Returns: The base 10 logarithm of val expressed as a real. A DOMAIN error will occur if val<0.0 and a SING error if val==0.

cos(number val)

Returns: The cosine of val (interpreted in radians) expressed as a real.

sin(number val)

Returns: The sine of val (interpreted in radians) expressed as a real.

tan(number val)

Returns: The tangent of val (interpreted in radians) expressed as a real

acos(number val)

Returns: The principal value of the arc cosine of val (interpreted in radians) expressed as a real in the range [0,pi] . A DOMAIN error will occur if val does not fall with in the range [-1,1].

asin(number val)

Returns: The principal value of the arc sine of val (interpreted in radians) expressed as a real in the range [-pi/2,pi/2] . A DOMAIN error will occur if val does not fall with in the range [-1, 1].

atan(number val)

Returns: The principal value of the arc tangent of val (interpreted in radians) expressed as a real in the range [-pi/2,pi/2] .

atan2(number y, number x)

Returns: The principal value of the arc tangent of y/x expressed as a real in the range [-pi/2,pi/2] . A DOMAIN occur error will occur if both y and x are 0.

cosh(number val)

Returns: The hyperbolic cosine of val expressed as a real. An OVERFLOW error may occur.

sinh(number val)

Returns: The hyperbolic sine of val expressed as a real. An OVERFLOW error may occur.

tanh(number val)

Returns: The hyperbolic tangent of val expressed as a real.

integerPart(number val)

Returns: The integer part of val expressed as a real. The returned value always has the same sign as val.

fractionPart(number val)

Returns: The fraction part of val expressed as a real. The returned value always has the same sign as val.

ceil(number val)

Returns: The smallest integral value not less than val expressed as a real.

fabs(number val)

Returns: The absolute value of val expressed as a real.

floor(number val)

Returns: The largest integral value not larger than val expressed as a real.

fmod(number x, number y)

Returns: The floating-point (real) remainder of x/y . That is, if r = fmod(x,y) , then EXISTS i , such that x = (i×y)+r , r has the same sign as x, the magnitude or r is less than that of y. A DOMAIN error may occur if y==0.

e()

Returns: The constant e at the significance of a real.

pi()

Returns: The constant pi at the significance of a real.

A.2.7 Handles

isValid(handle h)

Returns: TRUE if the handle is non-NULL and points to a valid object or variable, otherwise FALSE.

A.2.8 Classes and Inheritance

isKindOf(handle hObject, handle hClass)

Returns: TRUE if hObject points to an object (as opposed to a variable of base, compound or complex type), hClass points to a wrapped or ADL class, and hObject points to an instance of the class pointed to by hClass or to a class derived from it.

Notes: Pointers to classes are generally derived from expressions using the operators theClass or classOf (see Section 3.22, "Metaclass Operations" page 43).

className(handle hClass)

Returns: The string name of the class pointed to by the handle hClass or the null string if the class is anonymous.

Notes: Pointers to classes are generally derived from expressions using the operators theClass or classOf (see Section 3.22, "Metaclass Operations" page 43).

isDirectBaseOf( handle hSuspectedBaseClass, handle hKidClass )

Returns: boolean

Effects: If hSuspectBaseClass is a pointer to a direct base class of the class pointed to by hKidClass, returns TRUE, else FALSE.

Warning: It is a fatal error for either argument to be NULL or to not point to a class.

A.2.9 Networking

userName()

Returns: A string containing the name of the user executing AthenaMuse2.

hostName()

Returns: If Domain Name Service is enabled on the system, the fully qualified hostname is returned. Otherwise, the host table entry for the machine is returned. This may or may not be a fully qualified hostname depending on the format of the host table for the system.

A.2.1 - Input/Output
A.2.2 - Time and Date
A.2.3 - Conversion
A.2.4 - Type Query
A.2.5 - Sequences (lists and strings)
Lists
Strings
A.2.6 - Mathematical
A.2.7 - Handles
A.2.8 - Classes and Inheritance
A.2.9 - Networking

AM2 Documentation - 19 NOV 1996

Generated with Harlequin WebMaker