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

SET LEXTRACE

Controls lexical tracing.

Syntax

SET [LOCAL] LEXTRACE ON|OFF

Parameters

LOCALIndicates that lexical tracing is to be switched ON or OFF only at the “local” level.

Comments

The LEXTRACE option is set OFF by default.

When LEXTRACE is ON, each line of a procedure is displayed on the terminal, one character at a time, as it is parsed. Each line is preceded by the procedure name and document line number. If an error occurs, the resulting error message appears immediately following the character that caused the error.

Comment lines are traced. Carriage returns are inserted into the output when continuation characters (backslashes) are encountered. Statements are shown after macro substitution (if any) is complete.

Each output line starts with the procedure name and the application document line number as shown in the following example:

pCustReport[19] report from Customers

The SET LEXTRACE command has no effect on compiled procedures.

The SET LEXTRACE command is not affected by the SET RESET and SET RESTORE commands.

See Also

SET COMMANDTIMING

SET TRACE

SET TRACEOUTPUT

SET SINGLESTEP

Steps through a procedure one command at a time, halting after each command.

Syntax

SET SINGLESTEP ON|OFF

Comments

When SINGLESTEP is switched ON, execution is halted (by the HALT utility) after each command executed. To resume execution after the HALT, press Enter at the HALT prompt (>>).

Compiled application programs are not affected by SET SINGLESTEP.

The SET SINGLESTEP command is not affected by the SET RESET and SET RESTORE commands.

Example

To switch to singlestep, use

> set trace on
> set singlestep on

Now, if you execute an application program, it looks like this:

> DoCusts (“edit”)
procedure DoCusts (in ExMode)
>>output $setcount
35
>>(carriage return)
let dp = $true
>>.
.
.

See Also

SET STOP ERRORS

About Functional Expressions

The software provides a host of built-in functions that process given arguments in a variety of ways. An expression consisting of a function and its arguments (typically, value expressions) is called a functional expression.

Examples of functional expressions are

$length(‘Smith’)

Evaluates to 5

$cos(0)

Evaluates to 1

$log10(2*50)

Evaluates to 2

$year(19990923)

Evaluates to 1999

$maxof($absolute(-10),4+5)

Evaluates to 10

General Performance

Functions are a special class of operator, but they perform much like arithmetic operators; they take one or more given values, perform an operation using those values, and return a result. The value of the result depends on the function.

The function’s arguments are similar to the arithmetic operands. Like arithmetic operands, the arguments can consist of literals or value expressions, including other functional and arithmetic expressions as shown in the following example:

$absolute(-7)

The functional expression shown above consists of the argument -7 and the function keyword $absolute. The function $absolute returns the absolute (i.e., unsigned) value of its argument (in this case, 7).

Complex Arguments

If the argument is a complex expression, the argument is evaluated before the function is applied. For example, in the expression

$absolute(6-11)

the arithmetic expression 6-11 is evaluated first, yielding $absolute(-5). Then the final result (5) is determined.

Functional expressions can act as arguments to other functions. For example, the expression

$toupper($substring(‘abcdef’,2,3))

evaluates to

$toupper(‘bcd’)

which in turn evaluates to

‘BCD’

Data Type of Arguments and Results

Each function expects arguments of a certain data type; however, the function accepts arguments of any data type and appropriately converts any argument that does not conform to the expected type.

Related Information

About Data Types

About Data Types

Any value expression used in an application – including the names of objects that represent values – must conform to one of the available data types.

Data Types and Objects

Objects that represent values (constants, variables, fields and form fields) have an explicit data type attribute defined in the Object Dictionary. Value expressions that are not defined objects take implicit data types. The data type of an object or expression determines the values that an object or expression can represent and how the software handles the value.

The software recognizes nine different data types:

  • ALPHA, VARALPHA, CHAR and VARCHAR are character (string) data types.
  • INT, LONGINT, VASTINT, and NUMERIC are number data types.
  • DATE is a date data type.

See Also

Character Data Types

Conversion Between Data Types

Data Types and Storage of Values

Data Types and the Use of Database Indexes

How To Use Data Types

Implicit Data Types of Literals

Number Data Types

The Date Data Type

Character Data Types

Each character data type represents a particular combination of storage space usage and letter case treatment. ALPHA, VARALPHA, CHAR, and VARCHAR values can contain letters, digits, spaces, symbols, and hexadecimal codes.

Character Data Type Characteristics

Data TypeData LengthTreatment of Letter Case
ALPHAFixed (padded with trailing blanks if necessary)Case insensitive (but, case is stored and visible on display)
VARALPHAVariableCase insensitive (but, case is stored and visible on display)
CHARFixed (padded with trailing blanks if necessary)Case insensitive
VARCHARVariableCase insensitive

See Also

About Conditional Expressions

Conversion Between Data Types

Data Types and Storage of Values

Data Types and the Use of Database Indexes

How To Use Data Types

Number Data Types

INT, LONGINT, and VASTINT represent varying sizes of numbers and varying storage space usage, but otherwise receive identical treatment by the software. INT, LONGINT, and VASTINT values can contain only digits.

The NUMERIC data type represents numbers stored in character form and may therefore contain a leading sign (+, -) or an embedded decimal point, or both. Spaces are permitted before and after the leading sign, but not between digits.

Number Data Type Characteristics

Data TypeDecimalsValid Range
(Significant Digits)
Storage Occupied
INTAny number-32768 to 32767Two bytes
LONGINTAny number-2147483647 to 2147483647Four bytes
VASTINTAny number15 significant digitsEight bytes
NUMERICAny number15 digitsOne byte per character

See Also

About Conditional Expressions

Conversion Between Data Types

Data Types and Storage of Values

Data Types and the Use of Database Indexes

How To Use Data Types

The Date Data Type

DATE indicates that a value consists of eight digits representing a date in the form YYYYMMDD. For example, 19990821 is August 21, 1999.

Note: If you are using Zim in conjunction with a third-party SQL database engine, the format of dates can differ from that described here. In such cases, your code must avoid making any assumptions about the format of date fields.

Dates and numbers can be freely interchanged. When a number is converted to a date, the number is assumed to adhere to the YYYYMMDD format, so that dividing the number by 10,000 (for example) yields the year. You can subtract one date from another to find the number of days between them, or you can add or subtract a number of days to or from a date to generate another date (i.e., date arithmetic).

The software provides a number of functions to manipulate DATE values. These functions ($year, $ monthname, $ addmonths, $weekday, etc) are described in the Language Reference book of this online help.

Date Data Type Characteristics

Data TypeDecimalsValid RangeStorage Occupied
DATENoneJanuary 1, 0001 to December 31, 9999Eight bytes

See Also

About Conditional Expressions

Conversion Between Data Types

Data Types and Storage of Values

Data Types and the Use of Database Indexes

How To Use Data Types

How To Use Data Types

The following are the character data types:

  • alpha

  • varalpha

  • char

  • varchar

The following are the numeric data types:

  • int

  • longint

  • vastint

  • numeric

The following is the other data type:

  • date

Alpha Data Type

A character string of fixed length (uses a pre-defined amount of storage space). Pads with trailing blanks if necessary. Case insensitive in sorts, compares, and so on, but case is stored and is apparent on display.

Varalpha Data Type

A character string of variable length (uses only as much storage space as data requires). Ignores trailing blanks if entered. Case insensitive in sorts, compares, and so on, but case is stored and is apparent on display.

Char Data Type

A character string of fixed length (uses a pre-defined amount of storage space). Pads with trailing blanks if necessary. Case sensitive in sorts, compares, and so on.

Varchar Data Type

A character string of variable length (uses only as much storage space as data requires). Ignores trailing blanks if entered. Case sensitive in sorts, compares, and so on.

Int Data Type

A numeric value occupying two bytes of storage space. Can contain any number of decimal places, but digit value (ignoring decimal places) must fall between -32768 and 32767.

Longint Data Type

A numeric value occupying four bytes of storage space. Can contain any number of decimal places, but digit value (ignoring decimal places) must fall between -2147483648 and 2147483647.

Vastint Data Type

A numeric value occupying eight bytes of storage space. Can contain any number of decimal places and up to fifteen significant digits (ignoring decimal places).

Numeric Data Type

A number stored in character form. Can include a leading sign (+, -), or an embedded decimal point, or both. Can include spaces between the sign and the first digit, but not between digits.

Date Data Type

A date value occupying eight bytes of storage space. On display, contains eight digits in the form YYYYMMDD. Dates and numbers are freely interchangeable, and date arithmetic is available.

en_CAEnglish