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

abs()

Absolute value of a number

asc()

ASCII value of a character

datdif()

Number of days between two dates

dayofweek()

Gives the day number for the date (0 is Sunday ... 6 is Saturday)

instr$()

Position of a character in a string

int()

The whole (integer) part of a number

len()

The actual length of a character string

max()

The maximum value in a range of values

min()

The minimum value in a range of values

mod()

The integer remainder from the division of two values

ndays()

The number of days until (negative value) or since the beginning of 1900 (positive value)

repcnt()

The number of occurrences of a tag

repmax()

The maximum value in a tag

repmin()

The minimum value in a tag

repsum()

The total of occurrences of a tag

rinstr$()

The position of a character in a string

round()

The rounded value of a number

sqrt()

The square root of a number

val()

The numeric value of a character string

Operating system functions

date$()

Returns the system date as a string

getvar()

Reads the contents of a global system variable

setvar()

Puts a value in a global system variable

time$()

The system time as a character string

user$()

User name or user number as a character string

Text functions

after$()

Returns a substring to the right of indicated character(s)

before$()

Returns a substring to the left of indicated character(s)

chr$()

Returns a character from the ASCII table

cvt$$()

Converts from/to upper case

date$()

Returns the system date as a string

getvar()

Reads the contents of a global system variable

isolatintohtml$()

Converts a string from Isolatin to HTML

jstr$()

Justifies (left/right) or centres a line

left$()

The left part of a character string

mid$()

Any part of a character string

name$()

Changes ‘surname, first name’ to ‘first name surname’

recdate$()

Input or mutation date or time as a character string

regvalidate()

Validates a string to a regular expression

right$()

The right-hand part of a character string

round$()

The rounded value of a number

str$()

Converts a value to a character string

string$()

Generates a string of equal characters

tag2field$()

Returns the name of the tag as entered in the database setup. If no name is filled in there, the tag will be returned

text$()

Reads line from text file

time$()

The system time as a character string

trim$()

Removes leading and/or trailing blanks

user$()

User name or user number as character string

whatdate()

Returns a computed date as a character string

Record functions

fieldisrepeated

Checks if the provided field is a repeated field.

fieldlength

Yields the length of the provided field.

fieldtype

Yields the data type of the provided field.

null()

Deletes a field or field occurrence.

onchangein()

Has tag/field occurrence changed since last call?

reccopy()

Copies a complete record.

repcnt()

The number of occurrences of a tag.

repcopy()

Copies all occurrences from tag1 to tag2.

repins()

Inserts an occurrence into a tag.

repmax()

Returns occurrence with the highest value from a tag.

repmin()

Returns occurrence with the lowest value from a tag.

repsort()

Sorts the occurrences of a tag.

repsortins()

Inserts data into correct occurrence of a sorted tag.

repsum()

The total sum of the contents of all occurrences of a tag.

Terminal functions

yesno()

Asks the user to choose between two options