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

Event

A data structure that provides information about the state of the system and the most recent event.

The Event data structure provides information about the most recent event and about the state of the system when that event occurred.

The components of the Event data structure are set when an event occurs in the user interface. An application program can use the information in the fields to determine what action, if any, to take.

The fields in the Event structure are

– AltKey

– CtrlKey

– EventName

– EventTag

– EventType

– FieldTag

– FormTag

– KeyPressed

– MenuItemTag

– MenuTag

– MouseClick

– ScrollingKey

– ShiftKey

– WindowTag

Syntax #1 – AltKey, CtrlKey, ShiftKey

Provides information about the state of the Alt, Ctrl, or Shift key during the last event

event.altkey

event.ctrlkey

event.shiftkey

Return Value

Character string (binary). Can be reset by the application program.

Description

The variables provide information about the state of the Alt, Ctrl, and Shift keys during the last event.

The string is set to ‘1’ ($True) if the indicated key was down when the last event occurred. Otherwise, it is set to ‘0’ ($False).

Syntax #2 – EventName

event.eventname

Where eventname is one of

  • Break, Canceled, Click, Closed, DoubleClick, GotFocus, HangUp, LostFocus, LostFocusModified, Modified, PanicExit, RightClick, Timeout, WindowFocusSwitch, or
  • the name of an accelerator key, such as F1, if the event type was accelerator

Return Value

Character string (alpha). Can be reset by the application program.

Description

The Event data structure provides information about the most recent event and about the state of the system when that event occurred.

The components of the Event data structure are set when an event occurs in the user interface. An application program can use the information in the fields to determine what action, if any, to take.

Syntax #3 – EventTag

event.eventtag

Return Value

Character string (ALPHA). Can be reset by the application program.

Description

The variable identifies, by its tag, the object in which the last user interface event occurred. The variable can be

EventType SettingEventTag Value Taken From
WindowEvent.WindowTag
MenuEvent.MenuTag
MenuitemEvent.MenuItemTag
FormEvent.FormTag
FormfieldEvent.FieldTag
AcceleratorEvent.FieldTag
SystemEvent.FieldTag

Syntax #4 – EventType

event.eventtype

Return Value

Character string (ALPHA). Can be reset by the application program.

Description

The variable identifies the type of user interface event that last occurred.

– window

– menu

– menuitem

– form

– formfield

– accelerator

– system

Syntax #5 – FieldTag

event.fieldtag

Return Value

Character string (ALPHA). Can be reset by the application program.

Description

The variable identifies, by its tag, the current field at the time of the last event.

Syntax #6 – FormTag

event.formtag

Return Value

Character string (ALPHA). Can be reset by the application program.

Description

The variable, identifies, by its tag, the current form at the time of the last event.

Syntax #7 – KeyPressed

event.keypressed

Return Value

Character string (CHAR). Can be reset by the application program.

Description

The variable indicates, by name, the pressed key that caused the last event to occur.

Note: The keynames associated with accelerator events, such as F1, are recorded in EventName.

Example

If the user presses the a key in a form field and a Modified event is intercepted by the application program, then Event.KeyPressed is set to a.

Syntax #8 – MenuItemTag

event.menuitemtag

Return Value

Character string (ALPHA). Can be reset by the application program.

Description

The variable identifies, by its tag, the selected item on the menu in the current window at the time of the last event.

Syntax #9 – MenuTag

event.menutag

Return Value

Character string (ALPHA). Can be reset by the application program.

Description

The variable identifies, by its tag, the current menu at the time of the last event.

Syntax #10 – MouseClick

event.mouseclick

Return Value

Character string (binary). Can be reset by the application program.

Description

The variable indicates if a mouse button acceleration caused an event to occur.

It is set to ‘1’ ($True) if the event was caused by pressing a mouse button that is defined as an accelerator for the window. Otherwise, it is set to ‘0’ ($False).

Syntax #11 – ScrollingKey

event.scrollingkey

Return Value

Character string (ALPHA). Can be reset by the application program.

Description

The variable indicates if an event corresponds to a defined SCROLL key.

It is set to ‘1’ ($True) if an event corresponds to an accelerator key that is also a defined SCROLL key for the window. Otherwise, it is set to ‘0’ ($False).

Accelerators and SCROLL keys are defined using WINDOW SET commands.

Example

The application fragment that follows enables employee records to be scrolled through a form and the data to be updated. The combined actions are accomplished by defining certain keys both as accelerators and SCROLL keys. When one of these keys is pressed, the corresponding accelerator event occurs. The application program uses ScrollingKey to detect that a SCROLL key was pressed and performs the scrolling action after saving the updated data.

window set scroll Up F7 Down F8

window set accelerator F7 F8 escape

form open fEmployee

form set scroll fEmployee from EmpSet

form display

while

form input

if event.scrollingkey = $true

if thisform.formchanged = $true

  change EmpSet from fEmployee

   endif

  form scroll

  continue

endif

… other commands …

endwhile

Syntax #12 – WindowTag

event.windowtag

Return Value

Character string (ALPHA). Can be reset by the application program.

Description

The variable identifies, by its tag, the current window at the time of the last event.

See Also

FORM INPUT

FORM SET

MENU INPUT

MENU SET

RightClick

ThisForm

ThisMenu

WINDOW SET

WINDOW SET CURRENT

Makes an open window the current window.

Syntax

WINDOW SET [NOT] CURRENT [window]

Parameters

NOTPlaces window at the bottom of the currency stack.
windowThe name of an open window. Can be
a window object name, or
(expr), where expr is a character string, or an expression that evaluates to a character string, that is to be used at run time as a window object name. The parentheses must be entered.

Comments

Before you can use this command, the target window must be open (WINDOW OPEN command), though it need not be active (WINDOW ACTIVATE command). The target window becomes the current window, unless NOT is specified. If NOT is specified, the target window is moved to the bottom of the “stack” of OPEN windows.

See Also

ThisWindow

MENU INPUT

Shifts the focus to the open menu in the current window and puts the application user in control of the interface.

Syntax

MENU INPUT [PURGE]

Parameters

PURGESpecifies that unprocessed input received before the MENU INPUT command was executed is to be ignored. Eliminates the possible effects of inadvertent keystrokes or mouse actions before the application user is actually placed in control of the interface. PURGE is often used when the application user is required to confirm some action.

Comments

If the open menu is a pop-up menu that has not yet been displayed, MENU INPUT automatically displays the menu before requesting input.

The input focus remains within the menu until a selection is made or the menu is cancelled. Accelerator keys are ignored while the menu has focus. When the input request ends, the system variable ThisMenu returns information about the selected item.

See Also

$messagebox

FORM INPUT

INPUT

MENU CLOSE

MENU DISPLAY

MENU OPEN

MENU SET

ThisMenu

MENU CLOSE

Closes the open menu in the current window.

Syntax

MENU CLOSE [object]

Parameters

object

Can be
name
The name of the menu to be closed.
(expr )
A character string, or an expression that evaluates to a character string, used at run time as the name of the menu. Using expr enables one MENU CLOSE command to specify different menus, at the risk of encountering an ambiguous name.
If name or expr is omitted, MENU CLOSE closes the current menu in the current window. When name or expr is specified, MENU CLOSE closes the open menu only if its name matches the specified name.

Comments

A MENU CLOSE command implicitly causes any form, display, or menu open in the window to be closed.

The MENU CLOSE command with a menu name is effective only if the menu in the current window bears the exact name specified in the command.

Closing a menu removes that menu from the window. The window remains without a menu until a MENU OPEN command is executed.

 

See Also

FORM CLOSE

ThisMenu

FORM SET FOCUS

Sets the focus on a particular form field.

Syntax

FORM SET FOCUS «object»

Parameters

objectCan be
formfield
The name of a field within an open form. To specify a particular instance of a form field, append the instance number in brackets.
([exp1 ],[exp2 ],[exp3 ])
Positive integers or expressions that evaluate to positive integers, that identify a particular form field to receive focus. Exp1 identifies the form number; exp2, the field number; exp3, the instance of the form or form field in the display. At a minimum, exp2 must be specified.
Focus is placed on the specified field, or on the first available instance of the specified field. If all form fields specified in the command are unavailable, focus moves to the next available field.

Comments

Focus is positioned at the specified form field. If the field is unavailable, the focus moves to the next available field.

Example

form set focus fAddEmp.EmpNum[5]

form set focus (2,2,5)

See Also

FORM SET

SET CURSOR

FORM REPORT

Writes the values of the fields in the current form or display to the current output device.

Syntax

FORM REPORT [ PAGESIZE n]

Parameters

PAGESIZE nThe number of lines ( n) that constitute one “page” of output. The default PAGESIZE is 66 lines.
The output is padded with blank lines if the specified page size is greater than the number of lines in the form. PAGESIZE is independent of the size of the window or the terminal screen.

Comments

The form does not need to be displayed before FORM REPORT is executed.

Note: FORM REPORT works with Zim Version 4 windows only.

Example

form open fCustomer

change fCustomer from Customers where CustCode = “12345”

set output CustFormOut

form report

set output terminal

form close

The current form is stored, with the contents of its form fields, in an application document for later printing.

See Also

$screenprint

FORM OPEN

LIST

PRINT

REPORT FROM

FORM CLOSE

Closes the current form or display in the current window.

Syntax

FORM CLOSE [object]

Parameters

objectCan be
name
The name of the form or display to be closed.
( expr)
A character string, or an expression that evaluates to a character string, used at run time as the name of the form or display. Using expr enables one FORM CLOSE command to specify different forms or displays, at the risk of encountering an ambiguous name.
If name or expr is omitted, FORM CLOSE closes the current form or display in the current window. When name or expr is specified, FORM CLOSE closes the open form or display only if its name matches the specified name.

Comments

A WINDOW CLOSE command implicitly causes any form, display, or menu open in that window to be closed.

The FORM CLOSE command with a form name is effective only if the form in the current window bears the exact name specified in the command.

In a standard window, closing the form or display clears the fields of the form or display from the window. The window remains empty of content until another FORM OPEN command is executed.

See Also

MENU CLOSE

WINDOW CLOSE

FORM SCROLL

Causes scrolling under application program control.

Syntax

FORM SCROLL [ «form»] [action]

Parameters

form

The name of the form to be scrolled. Form must have an established scrolling association. More than one form can be scrolled at a time.

action

Can be

UP, DOWN, LEFT, RIGHT, PAGEUP, PAGEDOWN, HOME, END, JUMPUP, JUMPDOWN, JUMPLEFT, or JUMPRIGHT

If action is omitted, action is assumed to be implicit in the last user interface event that occurred. If the last event does not correspond to a defined SCROLL key, no scrolling occurs.

Comments

The FORM SCROLL command causes the specified scrolling action to occur under program control. If no form name is specified, the command applies to all forms for which a scrolling association has been established with a FORM SET SCROLL command.

The number of members scrolled depends on the LoadOrder defined for the form. If LoadOrder is row-major, the scrolling is row-based. If LoadOrder is column-major, the scrolling is column-based.

 

See Also

FORM INPUT

FORM SET

WINDOW SET SCROLL

MENU DISPLAY

Displays the open menu in the current window.

Syntax

MENU DISPLAY [INPUT] [PURGE] [«object»]

Parameters

INPUT

Shifts focus to the menu, and requests input from the application user.

PURGE

Shifts focus to the menu, and requests input from the application user.

object

Can be
menu
The name of the open menu in the current window.
menuitem
The name of a particular menu item in the open menu.
([exp1 ],[exp2 ],[exp3 ])
Positive integers or expressions that evaluate to positive integers, that identify a particular menu or menu item. Exp1 identifies the menu number; exp2, the item number. (Exp3 is reserved for future use.) Exp1, exp2, and exp3 must be positive integers or expressions that evaluate to positive integers. At least one of exp1 or exp2 must be specified.

Comments

For a bar menu, the INPUT parameter is optional.

For a pop-up menu, the INPUT parameter is mandatory. Focus shifts to the menu and input is requested from the application user. The focus remains within the pop-up menu until a selection is made or the menu is cancelled.

Related Information

 

See Also

MENU CLOSE

MENU INPUT

MENU OPEN

MENU SET

ThisMenu

en_CAEnglish