ADAPL functions
Introduction
ADAPL functions are built-in routines that compute a value from one or more arguments. You can use the result of a function for further calculations, or assign it to a variable. An ADAPL function is normally used as part of an expression. A function can also be used as an argument in another function. Each function has a unique name. A function is called in the following way:
variable=function(argument1,argument2,argument3, etc.)
The function in this example has three arguments, but in practice, the number of arguments may vary between none and many. Every function (except MIN and MAX) has a fixed number of arguments, of which the order is fixed too. For example:
text Name[10]
/* Assume a name:
Name = 'erik'
/* Convert first char to upper case:
Name[1] = cvt$$(left$(Name, 1), 1)
Some functions are used to execute tasks, in which case the value returned is irrelevant. ADAPL therefore allows functions to be used both in expressions and as independent instructions.
Function types
Functions fall into one or more of the following categories:
• | numeric functions |
• | operating system functions |
• | text functions |
• | record functions |
• | terminal functions |
Numeric functions
Absolute value of a number |
|
ASCII value of a character |
|
Number of days between two dates |
|
Gives the day number for the date (0 is Sunday ... 6 is Saturday) |
|
Position of a character in a string |
|
The whole (integer) part of a number |
|
The actual length of a character string |
|
The maximum value in a range of values |
|
The minimum value in a range of values |
|
The integer remainder from the division of two values |
|
The number of days until (negative value) or since the beginning of 1900 (positive value) |
|
The number of occurrences of a tag |
|
The maximum value in a tag |
|
The minimum value in a tag |
|
The total of occurrences of a tag |
|
The position of a character in a string |
|
The rounded value of a number |
|
The square root of a number |
|
The numeric value of a character string |
Operating system functions
Returns the system date as a string |
|
Reads the contents of a global system variable |
|
Puts a value in a global system variable |
|
The system time as a character string |
|
User name or user number as a character string |
Text functions
Returns a substring to the right of indicated character(s) |
|
Returns a substring to the left of indicated character(s) |
|
Returns a character from the ASCII table |
|
Converts from/to upper case |
|
Returns the system date as a string |
|
Reads the contents of a global system variable |
|
Converts a string from Isolatin to HTML |
|
Justifies (left/right) or centres a line |
|
The left part of a character string |
|
Any part of a character string |
|
Changes ‘surname, first name’ to ‘first name surname’ |
|
Input or mutation date or time as a character string |
|
Validates a string to a regular expression |
|
The right-hand part of a character string |
|
The rounded value of a number |
|
Converts a value to a character string |
|
Generates a string of equal characters |
|
Returns the name of the tag as entered in the database setup. If no name is filled in there, the tag will be returned |
|
Reads line from text file |
|
The system time as a character string |
|
Removes leading and/or trailing blanks |
|
User name or user number as character string |
|
Returns a computed date as a character string |
Record functions
Checks if the provided field is a repeated field. |
|
Yields the length of the provided field. |
|
Yields the data type of the provided field. |
|
Deletes a field or field occurrence. |
|
Has tag/field occurrence changed since last call? |
|
Copies a complete record. |
|
The number of occurrences of a tag. |
|
Copies all occurrences from tag1 to tag2. |
|
Inserts an occurrence into a tag. |
|
Returns occurrence with the highest value from a tag. |
|
Returns occurrence with the lowest value from a tag. |
|
Sorts the occurrences of a tag. |
|
Inserts data into correct occurrence of a sorted tag. |
|
The total sum of the contents of all occurrences of a tag. |
Terminal functions
Asks the user to choose between two options |