$random

Generates a pseudo-random number, uniformly distributed within the range 0 to 1.

Syntax

$random(number)

Parameters

numbera number, or an expression that evaluates to a number, that acts as a seed for the random number generator

Return Value

Number, with the same number of decimal places as number.

Comments

Use $random to generate a series of random numbers, by calling the function first with a seed value, and thereafter with $Null. The value returned by $random is a number in the range 0 to 1, with the same number of decimal places as number.

To pass the null property to $random, create a variable of a number data type (INT, LONGINT, VASTINT, numeric) and with the desired number of decimal places. Use this variable on subsequent calls to $random after seeding. (Remember that an uninitialized variable is always $Null.)

If you seed the random number generator with the same number on two or more different occasions, you obtain the same series of “random” numbers on the first call and subsequent ($Null) calls to $random.

Under some operating systems, the seed number is ignored; an internally generated seed is used instead.

When number is $Null, the random number generator is not reseeded.

Example

let seed = 9.999
let i = $random(seed)  % i might be set to 0.798 here
let seed = $null
let i = $random(seed)  % i might be set to 0.768 here
let i = $time
let i = $random(i)       % first call
  :
let i = $random(UninitVariable) % subsequent calls

Notice that $random($time) always returns 0 or 1, because $Time has no decimal places. Variable i is used to provide the necessary decimal places.

$right

Extracts a segment from the end of a character string.

Syntax

$right(source,length)

Parameters

sourcea character string, or an expression that evaluates to a character string
lengtha number, or an expression that evaluates to a number

Return Value

Character string, consisting of length characters from source, starting length character positions from the end of source.

Comments

Use $right to produce a string consisting of length characters from source, starting length character positions from the end of source.

If source is not of a character data type, it is converted to a character data type before the function is applied.

If length is zero or negative, the result is the null string.

If length is longer than source, the result is source.

Example

$right("abcdefgh",5)

Evaluates to “defgh”.

$right(1234,2)

Evaluates to “34”.

$right(1234567890,8)

Evaluates to “34567890”.

See Also

$concat

$delete

$insert

$left

$position

$replace

$substring

$translate

About Character Literals

About Functional Expressions

Conversion Between Data Types

NEXT

Moves the current member pointer one or more members down in a result set.

Syntax

DOWN [num] [setname]

Parameters

numThe number of members farther “down” into setname that the current member pointer is to be moved. Num can be
an integer constant (15, 200);
a variable, form field, or parameter that evaluates to an integer;
the word ALL.
The default value for num is 1. If num is negative, DOWN num actually moves the current member pointer “up” in the set.
setnameThe name of the result set whose current member pointer you wish to move. If setname is omitted, the current set is used.

Comments

NEXT is a synonym for DOWN.

Example

down 10

Moves the current member pointer 10 members “down” towards the end of the set.

down 5

delete 5

Moves the current member pointer five members “down” and then deletes five members (starting with the new current member).

find Customers -> CustSet

form open fCustomer

form set accelerator F1 F2 Escape

while

 change fCustomer from CustSet

 form display input

 if Event.EventName = “escape”

  break

 else    % use $direction as a handy variable

  let $direction = {-1 where Event.EventName = “F1”, 1}

 endif

 down $direction CustSet

endwhile

Finds a set of customers and then displays the records in the set one at a time.

See Also

$currentmember

BOTTOM

DOWN

LOCATE

PREVIOUS

TOP

UP

ACCESS

Opens an application directory to use the objects contained in it.

Syntax

ACCESS dirname [READ|UPDATE]

Parameters

dirname

Specifies the name of an application directory.

READ

Specifies that you can only read object definitions in dirname, not update object definitions. If neither READ nor UPDATE is specified, READ is the default value.

UPDATE

Specifies that you can read and update object definitions in dirname.

Comments

Initializing an application database (New Database) creates a base application directory called zim. Additional application directories are defined as objects in the application database. To access any directory other than the base application directory, you must issue an ACCESS command for that directory.

Once a directory has been accessed, objects in that directory are available for use. To close a directory (and its objects) to further access, use the RELEASE command.

Use the CREATE, ERASE, RENAME, PERMISSION, ENCRYPT, DECRYPT, COMPILE, UNCOMPILE, SET SIZE, and SET SELECTIVITY commands to change object definitions only in an application directory accessed using the UPDATE option.

By accessing a directory using the READ option, you prevent unwanted modification of the directory contents. Foreign directories can be accessed using READ only.

Example

To access directory ProjectControl in read-only mode, use

access ProjectControl read

or

access ProjectControl

To access the directory Personnel in update mode, use

access Personnel Update

 

See Also

$dirpath

COMPILE

CREATE

DECRYPT

ENCRYPT

ERASE

PERMISSION

RENAME

SET SELECTIVITY

SET SIZE

UNCOMPILE

UPDATE

( ) Parentheses

Alters the order of evaluation of expressions, or groups expressions, or both.

Syntax #1

Alters the order of evaluation in expressions.

(expression)

Within a larger expression, a single expression placed in parentheses changes the order of execution (which normally depends on the precedence of operators).

Parameters

expressionan arithmetic or logic expression

Syntax #2

Groups expressions.

(expression1, expression2)

Parentheses can be used to group several expressions, each of which is evaluated; the grouped expression takes on the value of the last individual expression in the group.

Parameters

expression1any expression
expression2any expression

Comments

Use parentheses to group one or more expressions, each of which is evaluated. The grouped expression takes on the value of the last expression in the group.

Examples

7 * 8 - 5^2
31
7 * (8 - 5)^2
63
not Salary > 30000 or Age < 25

Result: Logically true when Salary is 29,000 and Age is 21.

not (Salary > 30000 or Age < 25)

Result: Logically false when Salary is 29,000 and Age is 21.

w = ( (let x = 5+3), (let y = 5-3), (let z = 5^3), 5.0/3.0 )

Values: x=8, y=2, z=75, w=1.7

See Also

Conventions

How To Construct Logic Expressions

How To Use Logic Expressions

$distinct

Returns the unique values from a series of successive values.

Syntax

$distinct(expression)

Parameters

expressionany expression

Return Value

This function returns the unique values from a series of successive values. For each instance of its argument, $distinct returns a value that depends on the immediately previous value of the argument. If the previous and current values of the argument are equal, $distinct returns $Null. Otherwise, $distinct returns the current value of the argument.

Comments

It is important to sort the argument’s source values before using $distinct, because the value returned by the expression depends on the order in which the source values are processed.

Example

find Emps sorted by LastName
list all format LastName Salary

Prints the last names and salaries of all employees.

find Emps sorted by LastName
list all format $distinct(LastName) Salary

Prints the last names and salaries only of the employees who appear first in the list with a particular name.

find Emps sorted by LastName
list all where $distinct(LastName) is not $null format LastName

Prints a list of the last names of employees without repeating identical names.

report from Emps sorted by DeptNo LastName
break 1 DeptNo
footing
"No. of distinct last names in " deptno
"is" $count($distinct(LastName))
endreport

When used in a BREAK heading or footing, $distinct is reset for each break group. As a result, the first record in each break group is considered to be new, even if the value of the argument to $distinct is the same as the last value in the previous group. In the above report, even if the last employee in one department is named Smith and the first employee in the next is also Smith, the values are still considered to be distinct.

See Also

Functional Expressions

INTERSECT

MINUS

UNION

OR

Performs a Boolean OR of two logic expressions.

Syntax

expression1 OR expression2

Parameters

expression1A logic expression using conditional and Boolean operators. If the expression is complex, it must be enclosed in parentheses.
expression2A logic expression using conditional and Boolean operators. If the expression is complex, it must be enclosed in parentheses.

Return Value

Logical, as follows:

Truth Table for Boolean ORExpression1
TrueFalse
Expression2TrueTrueTrue
FalseFalseFalse

Example

The following expression is logically false only if Salary is 30,000 and Bonus is 0. In all other cases, the expression is logically true.

Salary <> 30000 or Bonus <> 0

See Also

About Boolean Expressions

About Conditional Expressions

\ (Escape)

Causes the following character to be treated literally, or as a hex code in a character string; indicates continuation of a command on the subsequent line.

Syntax #1

Causes the character that follows it in a string to be treated literally.

\char

Parameters

charany single character that is to be treated literally in a character string

Syntax #2

Causes certain characters that follow it in a string to be treated as hexadecimal code.

\char1char2

Parameters

char1either digits from 0 to 9, or letters from A (a) to F ( f), that together comprise a hexadecimal character code
char2either digits from 0 to 9, or letters from A (a) to F ( f), that together comprise a hexadecimal character code

Syntax #3

Indicates the continuation of a command onto a subsequent line.

commandstart \
remainder

Parameters

commandstartany portion, from the beginning, of one command
remainderthe remaining portion(s) of the same command

Comments

In a character string, the escape operator causes the next character to be treated literally or as a hex code. Outside of a character string, it indicates that a command continues on the next line.

Example

"This is a quote (\"); this is a backslash (\\)"
output "\0F"
let x = 10 \
    y = 5 \
    z = 2

See Also

About Character Literals

DOWN

Moves the current member pointer one or more members “down” in a result set.

Syntax

DOWN [num] [setname]

Parameters

numThe number of members farther “down” into setname that the current member pointer is to be moved. Num can be
an integer constant (15, 200);
a variable, form field, or parameter that evaluates to an integer;
the word ALL.
The default value for num is 1. If num is negative, DOWN num actually moves the current member pointer “up” in the set.
setnameThe name of the result set whose current member pointer you wish to move. If setname is omitted, the current set is used.

Comments

NEXT is a synonym for DOWN.

Example

down 10

Moves the current member pointer 10 members “down” towards the end of the set.

down 5

delete 5

Moves the current member pointer five members “down” and then deletes five members (starting with the new current member).

find Customers -> CustSet

form open fCustomer

form set accelerator F1 F2 Escape

while

change fCustomer from CustSet

form display input

if Event.EventName = “escape”

break

else    % use $direction as a handy variable

let $direction = {-1 where Event.EventName = “F1”, 1}

endif

down $direction CustSet

endwhile

Finds a set of customers and then displays the records in the set one at a time.

See Also

$currentmember

BOTTOM

LOCATE

NEXT

PREVIOUS

TOP

UP

$left

Extracts a segment from the front of a character string.

Syntax

$left(source,length)

Parameters

sourcea character string or an expression that evaluates to a character string
lengtha number or an expression that evaluates to a number

Return Value

Character string, consisting of a string containing length characters from source, starting in the first position.

Comments

Use $left to produce a string consisting of length characters from source, starting in the first position.

If source is not of a character data type, it is converted to a character data type before processing.

If length is zero or negative, the result is the null string. If length is longer than source, the result is source.

Example

$left("abcdefgh",5)

Evaluates to “abcde”.

$left(9999,1)

Evaluates to ” “, because numbers are converted to character strings containing seventeen characters before being processed by $left.

$left(1234567890,10)

Evaluates to ” 123″. Number literals convert to character strings containing seventeen characters before being processed by $left.

See Also

$concat

$delete

$insert

$position

$replace

$right

$substring

$toalpha

$tocharacter

$translate

en_CAEnglish