PROCEDURE

Starts and defines a procedure.

Syntax

PROCEDURE procname ([IN|OUT|INOUT] parm) [LOCAL (var)]

Parameters

procname

A valid object name. Procname must be the name of the existing application document that contains this procedure and must not conflict with a system keyword.

IN, OUT, or INOUT

Designates the direction in which the associated parm passes a value: Into the procedure (IN), out of the procedure (OUT), or both (INOUT).
If omitted, IN is assumed.

parm

The name of a parameter (a type of variable used only to carry values into and out of procedures). When more than one parameter is specified, they are separated from one another by commas.
If no parameters are defined, the enclosing parentheses must still appear.
A corresponding expression for each parameter is provided in the call to the procedure.

var

The name of the local variable whose use is restricted to within the local procedure. Local variables must be separated from one another by commas.

Comments

PROCEDURE declares the start of a procedure program. (A procedure program can have many local procedures, but only one main procedure.)

The call to the procedure must contain a corresponding expression for each parameter. The order of the expressions in the call must match the order of the parameters in the procedure declaration. If the number of expressions in the call differs from the number of declared parameters, then the call is ignored. Within the procedure, formal parameters are treated as if they were variables.

A PROCEDURE command must always have a corresponding ENDPROCEDURE command that marks the end of the procedure.

The number of formal parameters, plus the number of local variables, must not exceed the maximum parameters entry in the configuration file. The parameter size entry in the configuration file determines the maximum size of each formal parameter and local variable.

Example

procedure MyProc (item1, in item2, out item3, inout item 4)

Item1 and item2 are formal IN parameters, item3 is a formal OUT parameter, and item4 is a formal INOUT parameter.

procedure Summarize (DeptName, out AvgSalary) local (WorkVar)

WorkVar is a local variable (known only to procedure Summarize).

 

See Also

LOCALPROCEDURE

LOCALPROCEDURE

Defines and marks the start of a local procedure within an application program.

Syntax

LOCALPROCEDURE procname> ([IN|OUT|INOUT] parm)[LOCAL(var)]

Parameters

procname

 

A valid object name. The name of the local procedure cannot conflict with a software keyword. When a local procedure name conflicts with a pre-defined object name, the local procedure name takes precedence, provided the software is currently operating within the program that contains the local procedure.

 

IN, OUT, or INOUT

 

Designates the direction in which the associated parm passes a value: into the procedure (IN), out of the procedure (OUT), or both (INOUT).
If omitted, IN is assumed.

 

parm

 

The name of a parameter (a type of variable used only to carry values into and out of procedures). When more than one parameter is specified, they are separated from one another by commas.
If no parameters are defined, the enclosing parentheses must still appear.
A corresponding expression for each parameter is provided in the call to the local procedure.

 

var

 

The name of the local variable whose use is restricted to within the local procedure. Local variables must be separated from one another by commas.

 

Comments

The body of a local procedure is a sequence of commands. A LOCALPROCEDURE must always end with a corresponding ENDPROCEDURE command.

Local procedure declarations must appear at the beginning of their application program document, before the main procedure or before the commands of a macro program. A local procedure cannot be nested within the body of another procedure or local procedure. Local procedures obey all the same call/return rules as standard procedures, and possess the same capabilities as a standard procedure.

A local procedure can call other procedures in the same application program document or in other program documents. However, a local procedure can be called only by other procedures defined in the same program document.

Example

localprocedure LocalProc1 ()

 transform LocalProc2 ()

endprocedure

%——————————————-

localprocedure LocalProc2 ()

 output “Hi from LocalProc2”

endprocedure

%——————————————-

procedure MainProc (Param1, Param2)

  LocalProc1 ()

  LocalProc2 ()

endprocedure

The main procedure calls two local procedures. The first local procedure transfers control to the second through a TRANSFORM command.

 

See Also

ENDPROCEDURE

PROCEDURE

COLUMN BREAK

Breaks the body of column-oriented reports into summary groups.

Syntax

COLUMN BREAK level [HEADING reportitem [:format:]]

[FOOTING reportitem [:format:]]

Parameters

levelThe break level number (an integer greater than or equal to zero).
In the hierarchy of breaks, the higher the level number, the more minor the break. (For example, a level 1 break also triggers breaks at level 2, level 3, and so on.)
HEADINGIntroduces the “heading clause” for the break level, which can consist of a break orientation statement, a number of report items and their format instructions, or both. The footing displays each time the break level is triggered.
FOOTINGIntroduces the “footing clause” for the break level, which can consist of a break orientation statement, a number of report items and their format instructions, or both. The heading displays each time the break level is triggered.
reportitemAny valid expression that yields a value for display in the break heading or break footing. The heading and footing can each display a series of reportitems. Each item has its own associated format.
formatA set of instructions defining the format for the associated reportitem. Format is enclosed in : (colons) and can consist of any valid combination of format options.

Comments

The COLUMN BREAK command breaks the body of a column-oriented report into summary groupings.

Each time a BREAK command triggers a break at a specified level, the COLUMN BREAK for that level and all levels lower in the hierarchy are triggered.

Report items in the COLUMN BREAK heading can include individual values from the first member of the current group. Report items in the COLUMN BREAK footing can include individual values only from the last member of the current group. However, summary data computed over all members of the group can be displayed in the footing. Use aggregate functions.

If both the heading and footing clauses are omitted, a column break at the indicated level causes report formatting to recommence at the left-hand side of the page, beneath any previously formatted columns.

See Also

DETAIL LINE

ENDREPORT

REPORT FOOTING

REPORT FROM

REPORT HEADING

SET SELECTIVITY

Specifies index selectivity for indexed fields.

Syntax

SET SELECTIVITY fieldname value1 value2 value3

or

SET < fieldname> SELECTIVITY value1 value2 value3

Parameters

fieldnameThe name of an indexed field.
value1A number in the range 0.000 to 1.000. The number specifies the index selectivity for equality (=) searches.
A number above or below the acceptable range result in an error. A value1 of 1.000 instructs the software to use an internal default value for selectivity.
value2A number in the range 0.000 to 1.000. The number specifies the index selectivity for [NOT] BETWEEN searches.
A number above or below the acceptable range results in an error. A value2 of 1.000 instructs the software to use an internal default value for selectivity.
value3A number in the range 0.000 to 1.000. The number specifies the index selectivity for other searches (<, >, <=, >=).
A number above or below the acceptable range results in an error. A value3 of 1.000 instructs the software to use an internal default value for selectivity.

Comments

Index selectivity represents the fraction of records that you would expect to retrieve with a particular kind of search. For example, for an indexed field called Gender, you can expect an equality search to have a selectivity ratio (value1) of 0.500 (about half the records contain “male”; the other half, “female”). The strategy analyzer uses the values you supply to determine the best use of indexed fields in a retrieval operation.
The SET SELECTIVITY option has no effect on the Fields EntitySet in the Object Dictionary.
The SET SELECTIVITY option is not affected by the SET RESET and SET RESTORE commands.

Example

set selectivity Emps.Gender 0.5 0.5 0.5

set selectivity Emps.Age 0.02 0.1 0.5

The preceding commands indicate that Age is a more selective field than Gender. In a command such as find Emps where Age = 39, only about 2 per cent of the records in Emps are expected to be retrieved.

See Also

SET SIZE

$replace

Replaces a portion of a character string with another character string.

Syntax

$replace(source,position,length,string)

Parameters

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

Return Value

Character string, consisting of source, with the characters starting at position for a length of length replaced by the characters from string.

Comments

Use $replace to replace, in source, the characters starting at position for a length of length, with string.

In a string, the position of the first character is always 1. If position is beyond the end of source, or if position is zero or negative, then source is left unchanged.

If length is zero or negative, then string is embedded in source starting at position (effect is like $insert).

If there are fewer than length characters from position to the end of source, all characters from position to the end of source are replaced by string.

Example

$replace("abcdef",2,2,"123")

Evaluates to “a123def”.

See Also

$concat

$delete

$fill

$insert

$left

$position

$squeeze

$substring

$translate

About Character Literals

About Functional Expressions

SET COMMANDTIMING

Displays how much time each command takes to execute.

Syntax

SET COMMANDTIMING ON|OFF

Comments

The COMMANDTIMING option is set OFF by default.

The SET COMMANDTIMING command controls the output of command timing messages.

In UNIX, the format of command timing messages is

source, line, IU|RU, user ticks, elapsed user ticks, IS|RS, system ticks, elapsed system ticks

source

The name of the application document that contains the command; if it is the ZIM prompt, source is “”.

line

The line number of the line in the application document on which the command begin; if the value of source is “”, the value of line is a sequential number from the prompt.

IU|RU

Can be
IU (interpretive user execution)
RU (runtime user execution)

user ticks

The time it took to interpret the command (for interpretive execution) or the time it took to accept the command for processing (for compiled execution).

elapsed user ticks

The time it took to interpret the command, as seen by the user.

IS|RS

Can be
IS (interpretive user execution)
RS (runtime user execution)

system ticks

The system ticks used by the command. Usually, the system ticks value is lower than the user ticks value.

elapsed system ticks

The number of ticks spent by the execution of the command as seen by the system. Usually the elapsed system ticks value is lower than the elapsed user ticks value.

For Windows systems, the format of command timing messages is

source, line, I|R, user ticks, elapsed user ticks

source

The name of the application document that contains the command; if it is the ZIM prompt, source is “”.

line

The line number of the line in the application document on which the command begin; if the value of source is “”, the value of line is a sequential number from the prompt.

I|R

Can be
I (interpretive user execution)
R (runtime user execution)

user ticks

The time it took to interpret the command (for interpretive execution) or the time it took to accept the command for processing (for compiled execution).

elapsed user ticks

The time it took to interpret the command, as seen by the user.

 

See Also

SET LEXTRACE

SET TRACE

SET TRACEOUTPUT

=, <, <=, <>, >, >= (Condition)

Compares two expressions and returns a value of “true” or “false”.

Syntax

expression1
=
<
<=
<>
>
>=
expression2

Parameters

expression1any value expression
expression2any value expression

Return Value

Logical

Comments

In a conditional expression, the less than sign (<) compares the expressions to its left and right, and is logically true if the expression on the left is “smaller” than the expression on the right; otherwise, it is logically false.

In a conditional expression, the less than or equals sign (<=) compares the expressions to its left and right, and is logically true if the expression on the left is “smaller” than or equal to the expression on the right; otherwise, it is logically false.

In a conditional expression, the not equals sign (<>) compares the expressions to its left and right, and is logically true if they are not equal; otherwise, it is logically false.

In a conditional expression, the equals sign (=) compares the expressions to its left and right, and is logically true if they are equal; otherwise, it is logically false.

In a conditional expression, the greater than sign (>) compares the expressions to its left and right, and is logically true if the expression on the left is “larger” than the expression on the right; otherwise, it is logically false.

In a conditional expression, the greater than or equals sign (>=) compares the expressions to its left and right, and is logically true if the expression on the left is “larger” than or equal to the expression on the right; otherwise, it is logically false.

Examples

case
when GeoLocation = "New York"
... commands ...
otherwise
... more commands ...
endcase
while var1 < 11
... commands ...
var1 = var1 + 1
endwhile
DayCare = {"subsidized" where GIncome <= 22000, "not subsidized"}
case
when GeoLocation <> "Madrid"
... commands ...
otherwise
... more commands ...
endcase
case
when GoodsValue > 2000
... commands ...
otherwise
... more commands ...
endcase
case
when Age >= 65
... commands ...
otherwise
... more commands ...
endcase

See Also

About Conditional Expressions

About Data Types

SET SAVE

Saves the current global application settings in their current state for later use.

Syntax

SET SAVE

Comments

The SET SAVE command records the current state of all global settings, and pushes the group of settings onto a stack of previously saved settings (if any).

The SET SAVE command does not affect the SET WEBSOCKET setting.
The SET RESTORE command pops the top group of settings off the stack, thus restoring the values saved in that group.
The global application settings saved to the stack by SET SAVE include

SET AUTORETRYNOT APPLICABLESET CHECKNULLS
SET COLUMNSPACINGSET CURSORSET DELIMITER
SET DOCLINELENGTHSET EOFVALUESET ERRORS
SET ESCAPECHARSET HEADINGSSET INFORMATION
SET INPUT FORMATSET INPUT TIMEOUTSET MEMBERCOUNT
SET MEMBERINTERVALSET MESSAGESSET MESSAGES WINDOW
SET MOUSESET NULLVALUESET OUTPUT
SET OUTPUT FIELDLISTWIDTHSET OUTPUT FORMATSET OUTPUT MASKFIELD
SET OUTPUT TRIMSET OUTPUT VIRTUALFIELDSET PAGESIZE
SET PAGEWIDTHSET PAUSESET SPECIALSCAN
SET STRATEGYSET TEXTDELIMITERSET TIMEOUT
SET TRACE OUTPUTSET TRANSACTION FLOWSET WARNINGS

The SET SAVE command does not record the state of the following settings:

SET BREAKABLESET CHECKSETSSET CURRENTSET
SET DEPENDENCYSET EXCEPTIONSET FLOW
SET LEXTRACESET QUOTINGSET RUNTIME
SET SELECTIVITYSET SINGLESTEPSET SIZE
SET STOP ERRORSSET TRACESET XREF

Example

set save
set output MyDoc
set headings off
set pause off
set pagewidth 100
set pagesize 100
list all Employees
set restore

In the preceding example, SET SAVE saves the current state of the global settings before OUTPUT, HEADINGS, PAUSE, PAGEWIDTH, and PAGESIZE are adjusted to send data to an application document. SET RESTORE then returns the settings to their previous values.

See Also

SET RESET

$compilestatus

Checks if an application program needs to be recompiled.

Syntax

$compilestatus(docname)

Parameters

docnamethe name of an application document (not in quotation marks)

Return Value

Number, with no decimal places.

Comments

$compilestatus checks, in order, a series of conditions in relation to docname. As soon as docname fails to meet a condition, $compilestatus returns the code number (1 through 8) associated with that condition. If docname meets all the conditions, $compilestatus returns a 0.
A $compilestatus expression can be compiled, but its value is fixed at compile time and does not change thereafter.

CodeCondition
1The docname is not currently compiled.
2The source file for docname is missing.
3The compiled file for docname is missing.
4The source file bears a date more recent than that of the compiled file.
5No dependency information could be found for docname.
6The dependency information predates the most recent compile and could therefore be out of date.
7An object that docname depends on could not be found, it can be erased or located in an unaccessed directory.
8An object that docname depends on has been modified since docname was last compiled.
0No inconsistencies in the compilation status of docname were noted.

Example

let status = $compilestatus(MyZIMProgram)
case
   when status = 0
      output "No need to compile"
   when status =2
      output "No source file"
   when status = 7
      output "Could not find a dependent object"
   otherwise
      compile MyZIMProgram
endcase

CASE

Enables conditional execution of commands.

Syntax

CASE

WHEN expression

commands1

[OTHERWISE

commands2]

ENDCASE

Parameters

expressionA logical expression (using conditional or Boolean operators).
commands1Commands that are executed if expression is logically true.
commands2Commands that are executed if expression is logically false.

Comments

A CASE command must always have a corresponding ENDCASE. Any number of WHEN clauses can appear between CASE and ENDCASE.

The WHEN phrases between CASE and ENDCASE are evaluated in order. Execution control transfers to the commands associated with the first WHEN clause whose expression is determined to be logically true. If none of the WHEN phrases contain an expression that evaluates to “true”, the commands associated with OTHERWISE (if used) are executed. Execution then resumes at the first command following ENDCASE.

If a WHEN expression includes fields from the current set, then the expression uses the values found in the current member of the current set.

If a BYE, RETURN, STOP, or TRANSFORM command exits a procedure in the middle of a CASE structure, the “open” CASE command is automatically closed. Also, if the end of the current procedure is reached before a necessary ENDCASE is encountered, the “open” CASE command is closed.

If the ENDCASE is missing, all subsequent commands in the current procedure are treated as part of the CASE structure.

Example

If the value for salary is neither less than 20,000, nor between 20,00 and 30,000, the first and second set of commands are skipped, and the third set of commands executed.

case

when salary < 20000

… first set of commands …

when Salary between 20000 and 20000

… second set of commands …

otherwise

… third set of commands …

endcase

The following program fragment illustrates how WHEN conditions in a CASE command can handle an application user’s choice of accelerator keys in an application. Depending on the key pressed by the application user, a particular procedure is executed.

form display input

case

when Event.EventName = “F3”

return

when Event.EventName = “F1”

AddNewRecord ()

when Event.EventName = “F2”

ChangeRecord ()

when Event.EventName = “F4”

DeleteRecord()

otherwise

GiveHelp ()

endcase

pt_BRPortuguese