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

ThisMenu

ThisMenu

A data structure that provides information about the state of the system and of the current menu at the time of the last event in that menu.

The ThisMenu data structure provides information about the state of the system and of the current menu at the time of the last event in the current window.

The ThisMenu structure contains a number of fields that are reset when the current window changes. An application program can use the information in the fields to determine what action, if any, to take.

The fields in the ThisMenu structure are:

MenuChanged, MenuItemNum, MenuItemTag, MenuNum, MenuTag

Syntax #1 – MenuChanged

Indicates if any menu item in the current menu had been modified by the application user at the time of the last

thismenu.menuchanged

Return Value

“1” ($True), or “0” ($False). Can be reset by an application program.

Description

Set to “1” ($True) if the value of any menu item in the current menu changed after the application user was placed in control of the interface. Otherwise, set to “0” ($False).

Syntax #2 – MenuItemNum

The identification number of the selected menu item on the menu at the time of the last event in the current window.

thsimenu.menuitemnum

Return Value

A number. Can be reset by an application program.

Description

The identification number of the selected item on the menu at the time of the last event in the current window.

The combination of ThisMenu.MenuItemNum and ThisMenu.MenuNum can uniquely identify a particular menu selection.

Syntax #3 – MenuItemTag

The tag of the selected menu item on the menu at the time of the last event in the current window.

thismenu.menuitemtag

Return Value

A character string. Can be reset by an application program.

Description

The identification tag of the selected item on the menu at the time of the last event in the current window.

Syntax #4 – MenuNum

The identification number of the current menu at the time of the last event in the current window.

thismenu.menunum

Return Value

A number. Can be reset by an application program.

Description

The identification number of the current menu at the time of the last event in the current window.

The combination of ThisMenu.MenuItemNum and ThisMenu.MenuNum uniquely identify a particular menu selection.

Syntax #5 – MenuTag

The tag of the current menu at the time of the last event in the current window.

thismenu.menutag

Return Value

A character string. Can be reset by an application program.

Description

The identification tag of the current menu at the time of the last event in the current window.

See Also

FORM INPUT

FORM SET

MENU INPUT

MENU SET

SCREEN CLEAR

SCREEN RESET

ThisForm

ThisWindow

WINDOW CLOSE

WINDOW OPEN

WINDOW SET

WINDOW SET CURRENT

PERMISSION

Grants permission to other users to access your data.

Syntax #1

Sets permission for access to EntitySets or relationships.

PERMISSION object who [READ] [ADD] [CHANGE] [DELETE]

Parameters

objectSpecifies the name of an EntitySet or relationship.
whoIdentifies the users to whom the specified object permissions apply; who can be
OWNER
Anyone who shares the UserID under which object was created.
GROUP
Anyone who shares the GroupID under which object was created.
OTHER
Everyone else.
READGives the designated users permission to read the contents of object.
ADDGives the designated users permission to add to the contents of object (implies READ).
CHANGEGives the designated users permission to change the contents of object (implies READ).
DELETEGives the designated users permission to delete the contents of object (implies READ).

Syntax #2

Sets permission for access to fields or application directories.

PERMISSION object who [READ] [UPDATE]

Parameters

objectSpecifies the fully qualified name of an application directory of field.
whoIdentifies the users to whom the specified object permissions apply; who can be
OWNER
Anyone who shares the UserID under which object was created.
GROUP
Anyone who shares the GroupID under which object was created.
OTHER
Everyone else.
READGives the designated users permission to read the contents of object.
UPDATEGives the designated users permission to update the contents of object.

Comments

Only the owner of an object can reset that object’s permissions.

To access a directory, you must have READ or UPDATE permission. To CREATE, ERASE, or RENAME objects in a directory, you must have UPDATE permission. By default, all users have UPDATE permission in a directory.

Example

permission Employees owner add change

Gives only add or change permission to the owner.

permission Employees other

Gives no access by users outside the owner’s group.

permission Employees.LastName group read update

Users in owner’s group can read but not update.

permission MyDir group update

permission MyDir other

Users in the owner’s group can read the MyDir directory and can create, erase, or rename objects in it. Other users are to have no access to MyDir.

See Also

object permissions

WHILE

Enables repeated execution of a block of command.

Syntax

WHILE [expression]

commands

ENDWHILE

Parameters

expressionA logic expression.
If expression includes fields from the current set, then it is evaluated using the values of the specified fields in the current member of the set.
ENDWHILEMarks the end of the WHILE structure. A WHILE command must always have a corresponding ENDWHILE.
If a necessary ENDWHILE is missing, all subsequent commands in the current procedure are treated as part of the WHILE structure, and all of those commands continue to be executed as long as expression is true. When the end of the procedure is reached, the “open” WHILE command is closed.

Comments

The WHILE … ENDWHILE structure enables a block of commands to be repeatedly executed, as long as expression is logically true.

As soon as the software detects that expression is logically false, execution resumes at the first command following the ENDWHILE. To exit a loop before expression evaluates to false, use a BREAK command.

An open WHILE loop is automatically closed if

  • you exit a procedure in the middle of a WHILE structure (using a BYE, RETURN, STOP, or TRANSFORM command), or
  • a procedure ends before the ENDWHILE is encountered.

Example

% Commands to select and display form fDispEmp

%

——————————————————————-

find all Employees       % Create set of all Employees

while $setcount > 0      % Loop until end of set

  change fDispEmp from current  % Fill form with emp. data

  form display nolabel input    % Display form and start input

  if Event.EventName = “Escape”  % Check for Escape key

  return           % If so, finish

  endif

  if ThisForm.FormChanged = $true % Check if data modified

  change current from fDispEmp % Update current member

  endif

  next            % Go to next record

  let $setcount = $setcount – 1   % Decrement $setcount

endwhile

while Age > 20

 … other commands …

% Missing endwhile statement

… more commands …

last command in procedure

In the preceding example, the commands subsequent to the missing ENDWHILE command are executed as if they were a part of the WHILE structure. When the end of the procedure is reached without encountering the necessary ENDWHILE, it generates an error message.

form open fCustomers

while

 form display input

 … more commands …

 if Event.EventName = “Escape”

  break

 endif

…more commands …

endwhile

Notice in the preceding command that a BREAK (or BYE, RETURN, STOP, or TRANSFORM) command is required to exit a WHILE loop that contains no logic expression.

See Also

Boolean Expressions

Conditional Expressions

CONTINUE

LIST

Lists data from the database.

Syntax

LIST [ num] [ setspec] [EVALUATE clause ] [FORMAT expression [HEADING expression]] [-> clause]

Parameters

numThe number of records to be listed. Num can be
an integer constant (e.g., 15, 200);
a variable, form field, menu item, or formal parameter that evaluates to an integer;
the word ALL.
If num is less than zero, or omitted, num defaults to 1.
setspecA set specification whose members are to be listed. If setspec is omitted, the current set (if available) is used.
expressionAny expression. Enclose complex expressions in parentheses.
heading

A character string or an expression that evaluates to a character string.

Comments

The LIST command outputs num members of source to the current output device (usually the terminal).

By default, each column has a heading consisting of the field name. Headings can be suppressed using the SET HEADINGS command.

The width of each column is determined by these rules:

  • Unless a “LIST width” has been defined, character values occupy a width equal to their defined object length.
  • Unless a “LIST width” has been defined, number values are converted to their character equivalents, using the maximum width required for the particular data type (e.g., INT converts to eight characters).
  • If defined, the “LIST width” determines the width of a column (if 0 or $Null, the implicit width is used; if -1, the field is not LISTed).
  • If headings are to be output, widths are appropriately extended for longer headings.
  • If a character-manipulating function reduces the length of values being output, the output width is not reduced.
  • The $toalpha and $tocharacter functions can be used to specify the width of a column in LISTed output.

The HEADING option, always used in conjunction with FORMAT, establishes the heading that will be displayed above the corresponding expression, in place of any other heading that ZIM otherwise would be displaying. This option particularly useful whenever the expression is not a single field, thus normally not displaying any headings.

Output is also controlled by the SET PAGESIZE, SET PAGEWIDTH, and SET PAUSE commands.

Example

list all Employees format LName FName (($date – BirthDate)/365)

The complex expression is enclosed in parentheses.

list all Employees format LName heading “LastName” FName(($date-BirthDate)/365)

It will list three fields whose headings are: “Last Name”, “FName” and “Age of Employee”.

list

The current member of the current set is listed.

list all format $count(“”) LName FName Age

All members of the current set are listed with sequence numbers.

See Also

OUTPUT

REPORT FROM

SELECT

SET PAGESIZE

SET PAGEWIDTH

SET PAUSE

DEPENDENCY

Produces or deletes object dependency information.

Syntax

DEPENDENCY [RESET] [FOR] [object]

Parameters

RESET

Instructs the software to delete all saved dependency information for the specified object(s). If no object is named, all dependency information is deleted.

object

The name of an object for which you want to output dependency information, or whose dependency information you want to delete.

Comments

Object dependency information is captured during ERASE, CREATE, COMPILE, and PARSE commands if a SET DEPENDENCY ON command has been issued. The DEPENDENCY command either deletes this information or sends it to the current output. When dependency information is output, each dependency occupies one line and the output contains the following fields:

Flags

The first character can be
S if the dependency is for a system-defined object.
P if the dependency results from a reference by an application program.
O in all other cases (the dependency is an owner-object).
The second character can be
X if the dependent object is more recent than the time of program compilation (for a program dependency) or the time of creation of the owner-object (for an owner dependency).

ObjectName

The name of object (whose dependent objects are being displayed).

ObjectType

The object type of ObjectName

ObjectDirName

The application directory location of OwnerObjectName.

OwnerObjectName

The name of the object that owns object (i.e., if object is a field, then OwnerObjectName is the name of the EntitySet, relationship, or application document that owns that field).

OwnerObjectType

The object type of OwnerObjectName.

OwnerObjectDirName

The application directory location of OwnerObjectName.

DepObjectName

The name of an object that depends on ObjectName.

DepObjectType

The object type of DepOwnerObjName.

DepObjectDirName

The application directory location of DepObjectName.

DepOwnerObjName

The object name of  DepObjectName.

DepOwnerObjType

The object type of DepObjectName.

DepOwnerObjDirName

The application directory location of DepOwnerObjName.

Example

Consider a one-line application document called Test:

list e1

To produce dependency information for Test, enter

> set dependency on      % on by default

> parse TestProg

> dependency for TestProg

that outputs

O Test Document ZIM ZIM Directory ZIM

P Test Document ZIM ZIM Directory ZIM e1 EntitySet ZIM ZIM Directory ZIM

 

See Also

$compilestatus

COMPILE

PARSE

SET DEPENDENCY

SET OUTPUT

SET XREF

 

SYSTEM

Sends a command to the operating system.

Syntax

SYSTEM expression [RESET|CLOSE] [INVISIBLE] [BACKGROUND | REMOTE]

Parameters

expressionAny expression that evaluates to a character string. Expression may include constants, variables, parameters, functions, and so on.
RESETCauses all of the software’s internal data buffers to be flushed to disk.
CLOSEThe CLOSE option does not do anything anymore and it is ignored.
INVISIBLEAllows the command specified in expression to be executed without affecting the screen display.
BACKGROUNDIndicates that the command specified in expression is to be executed asynchronously while Zim continues to run. Many operating system commands can be processed concurrently.
When BACKGROUND is omitted, execution is suspended while the operating system executes the specified command.
REMOTEOnly applicable to Zim Thin Client, it executes the operating system command specified in expression in the server side.

Comments

SYSTEM sends the command represented by expression to the operating system. For expression to be successfully executed, it must be meaningful to the operating system. Any software required for the execution of expression must be available to the system.
The SYSTEM command runs synchronously by default; the BACKGROUND subcommand can be used to force any SYSTEM command to execute asynchronously.

Note: For batch files, precede the command with an exclamation mark (!).

Note: There is no sense issuing the command SYSTEM with CMD, COMMAND or SH and the option BACKGROUND because it will require user interaction but there is no visible window to do it. The result is that Zim will wait for an event (closing the operating system window) that will never occur.

Note: The CLOSE option is ignored in Zim 9. Until Zim 7.x, it was intended to be able to copy Zim files around while guaranteeing that they would not be in a volatile state. Now, ZimServer possesses all Zim files and they cannot be closed or moved around at will because this creates breaches in the database security. In a well maintained working environment, users never have access to the Zim database files located in the server machine, thus ensuring maximum safety and security of the database. The only exception is when dealing with PER USER files: in this case, there is the statement INITIALIZE PERUSER which creates per user file on the fly without the need of copying any Zim files around nor saving “blank” copies of these files.

Example

find Customers where LastName = “Smith” and FirstName = “John”

system $concat(“archive “, fCustomers.cc, “.dat”)

If the cc value is 7592, then this command invokes a program called “archive” to archive the data file by passing the command archive 7592.dat to the operating system.

system “erase c:\\file.dat”

In systems where the path delimiter character is the backslash, remember that the backslash is also the escape character in character strings. Two backslashes are required, as shown above, to send the backslash to the operating system.

set escapechar off

system “erase c:\\file.dat”

set escapechar on

In the above example, SET ESCAPECHAR is used to turn off use of the escape character in character strings. Or, use SET SPECIALSCAN to switch off use of all reserved characters in text strings.

Note: See the user documentation for your operating system.

See Also

EDIT

GRAPH

INITIALIZE PERUSER

ERASE

Erases an object from an application directory.

Syntax #1

Erases an object from an application directory.

ERASE object name [FROM dirname] [KEEP]

Parameters

object

One of
constant, directory, display, document, EntitySet, form, menu, relationship, role, set, variable, window

name

The name of the object.

dirname

The name of the application directory from which object is erased.

KEEP

The database file associated with objname is not erased from the file system.

Comments

The ERASE command erases an object from an application directory. If dirname is not specified, object is erased from the base application directory, zim.

The target directory must have been accessed in update mode. You cannot erase objects from foreign directories.

For ERASE to proceed, the explicit dirname in the ERASE command (or the implicit directory zim) must match the owner-directory of object. Qualifying the name of object is a recommended programming practice.

Syntax #2

Erases an index belonging to a specified object.

ERASE INDEX ownername.fieldname

Parameters

ownername

The name of the EntitySet, relationship with fields, or structured application document to which fieldname belongs.

fieldname

The name of the field whose index is to be erased.

Syntax #3

Erases a field belonging to a specified object.

ERASE FIELD ownername fieldname

Parameters

ownername

The name of the EntitySet, relationship with fields, or structured application document to which fieldname belongs.

fieldname

The name of the field to be erased. Only virtual fields can be erased.

Comments

Only virtual fields can be erased.

If you erase an EntitySet or relationship with fields, all data in that object is lost. To save the data, copy it to another object (usually an EntitySet or application document), or use the UNLOAD or RELOAD programs to temporarily store the data elsewhere.
If you erase an application document, the data in the associated disk file remains untouched.

Example

erase entityset Employees from Personnel

Erases the EntitySet Employees from the Personnel directory.

erase relationship BelongsTo

Erases the relationship BelongsTo from the Zim application directory.

 

See Also

CREATE

CURSOR

PERMISSION

RENAME

en_CAEnglish