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 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

$fill

Fills part of a string with a specified character

Syntax

$fill(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 filled with the first character from string, starting at position, for a length of length.

Comments

Use $fill to initialize strings to specific values. The function fills source with the (first) character from string, starting at position, for length number of characters. The fill character replaces any characters that already exist in the string in the specified positions.

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 source is left unchanged.

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

If string is the null string, then a space is used as the fill character.

Example

$fill(Title,1,$length(Title)," ")

The above expression fills Title with spaces.

See Also

$concat

$delete

$insert

$left

$position

$replace

$right

$squeeze

$substring

$translate

About Character Literals

About Functional Expressions

FIND

Finds records that match specified conditions, producing a result set.

Syntax

FIND [ num] [ setspec] [EVALUATE clause] [-> clause]

Parameters

numThe number of records to be found. Num can be
an integer constant (15, 200);
a variable, form field, or parameter that evaluates to an integer;
the word ALL.
If num is omitted, or less than 0, it defaults to ALL.
setspecThe set specification that defines the records to be found. If omitted, the current set (if it exists) is used.

Comments

Sets found using the FIND command are not stored permanently; they exist only for the current application session or until a DISPOSE SET command is executed.
If the -> clause is omitted, a result set is still produced. The unnamed result set can be referred to as CurrentSet for as long as it remains the current set.
Changes made to a record in an EntitySet or relationship are reflected in the result set, and vice versa.
$ SetCount and $ MemberCount are assigned a value equal to the number of members in the result set found by the FIND command.

Example

To find all employees whose last name is Smith, enter

find all Employees where LastName = “Smith” -> SmithSet

If you are working interactively at the command prompt, you could find it convenient to use the current unnamed result set when narrowing down a set of records. In the repeated FIND command, the second and third commands use the current set as their implicit setpsec:

> find Employees where Location = “Canada”

2019 selected

> find where LastName = “S”?

146 selected

> find where DeptNum = “D01”

7 selected

The name CurrentSet can also be used explicitly.
In application programs, you should explicitly name the result sets that you create with a FIND command. This technique is especially useful if you plan to compile a program that contains FIND commands:

procedure GetSet1 (a, b)

if a=b

find all Employees WorkIn Department -> KeepEmps

else

find all Employees WorkIn Department where LastName = a -> KeepEmps

endif

list all KeepEmps

endprocedure

You can use the FIND command to locate data, as shown in the following example:

find all Employees where LName = fEmployees.LastName

if $ setcount > 0

list all

else

  output “Nobody who works here is named: ” fEmployees.LastName

endif

You can also use FIND with forms as shown below:

find fItems where fItems.Qty > 0  % find values entered

See Also

$MemberCount

$SetCount

COMPUTE

INTERSECT

MINUS

UNION

SET RESTORE

Restores the top group of settings in the stack of saved global settings created by SET SAVE.

Syntax

SET RESTORE

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 RESTORE command pops the top group of settings off the stack, thus restoring the values saved in that group.
The global application settings reset to their defaults by SET RESTORE 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 RESTORE 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 SET OUTPUT, SET HEADINGS, SET PAUSE, SET PAGEWIDTH, and SET PAGESIZE are adjusted to send data to an application document. SET RESTORE then returns the settings to their previous values.

See Also

SET RESET

pt_BRPortuguese