Case Sensitivity

Except in certain limited instances (e.g., security passwords, values held in objects of data type CHAR and VARCHAR), the software is case insensitive. Insensitivity to case means that the software makes no distinction between uppercase and lowercase letters in any part of a statement. For example, the following statements are identical, provided LastName is not a CHAR or VARCHAR field:

list all employees where lastname = ‘smith’

LIST ALL EMPLOYEES WHERE LASTNAME = ‘SMITH’

lIsT aLl EmPlOyEeS wHeRe LaStNaMe = ‘SmItH’

list all employees where LastName = ‘Smith’

Normally, in a statement, you can use the combination of uppercase and lowercase letters that makes the statement most readable.

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.
  • Output Masks

    Output masks are employed to format the output of fields, form fields, and data values in output operations. The MASK format option in Zim Reports specifies an output mask pattern for a report item. The $mask function specifies an output masking pattern to be applied to fields, form fields, and data values and returns a character string with the result of the masking operation. The Field Mask attribute defines the expected output format of a field’s data value when it is printed or listed in Zim Reports, or by the list or output commands.   Mask patterns used with any of the three options described above are constructed in the same manner using the same set of available characters. However, the set of characters available varies according to the data type of the item being masked. For more information on mask patterns and their relation to data types, see Masking.

    Selected Examples of Mask Patterns for Numbers

    In the following examples, leading or trailing spaces are indicated by / in the Output column.

    Output of Sign Placeholders

    Sign PlaceholderOutput When Masked Value <0Output When masked Value >=0
    ‘-‘/
    ‘+’+
    ‘CR’CR//
    ‘DB’DB//
    ‘)’)/
    ‘(‘(/

    Behaviour of Fixed Text Characters

    Output Mask PatternItem ValueOutput
    ‘ZZ/ZZZZ’1234///1234
    ‘ZZ/ZZZZ’12345/1/2345
    ‘Z9/ZZZZ’1234/0/1234
    ‘***,***’999****999

    Behaviour of Float Characters

    Output Mask PatternItem ValueOutput
    ‘$$$,$$9.99CR’1324.77/$1,324.77//
    ‘$$$,$$9.99CR’-56.88////$56.88CR
    ‘$$,$$9.99DB’-2566.44$2,566.44DB
    ‘$$,$$9.99DB’.00/////$.00//
    ‘$,$$9.99+’1324.771,324.77+
    ‘$$$9.99+’-56.88/$56.88-
    ‘(((9,999,99)’-1324.82//(1,324.82)
    ‘((ZZ,999.99)’-386.41//( 386.41)
    ‘$.$$’0.00////
    ‘($$,$$9.99)’-56.88///($56.88)
    ‘($$,$$9.99)’-5.2////($5.20)
    ‘+$$,$$$.99’-56.88///-$56.88
    ‘+$$,$$$.99’2562.55+$2,562.55

    Mask Patterns and the Language Customizer

    Certain characters inserted into the output value by a mask are defined internally in the software. The Language Customizer (ZIMLANG) administrative utility is used to redefine the internal characters and strings used by the software in a variety of circumstances, such as output masks.

     

    For example, the currency placeholder $,  is by default the dollar sign $. However, it can be redefined to output other symbols, such as the Euro sign , the pound sign  £, etc. To achieve this, the Language Customizer can redefine the currency symbol output by the currency placeholder.

     

    When using the Language Customizer to edit the software’s internal characters and strings, note the following:

    • In application programs, output masks are always specified using the standard mask pattern characters. This rule applies to mask patterns specified in reports, in field and form field definitions, and in the $mask function.
    • In user interface displays and output, the characters output by a mask pattern are determined by the software’s internal values.

    For example, in Zim application programs, the dollar sign $ is universally used as the currency placeholder. However, the currency symbol output by the placeholder depends on the current language customization (if any).

    Report Item Format Options

    Any meaningful combination of the following options can be applied to any value displayed in a report:

    CENTERThe Report Generator is to center the associated item on the current line. Centering is relative to the PAGEWIDTH specified in the REPORT FROM command. The default value for PAGEWIDTH is 80.
    COLUMN nThe Report Generator is to start display of the associated item at character column n. COLUMN cannot be used in conjunction with SPACES. COLUMN 1 is automatic for the first item in each heading or detail line command.
    HEADING ‘text’The Report Generator is to use text as the heading for the associated item. (Normally, the heading depends on the source of the item: field names for fields from EntitySets and so on; object names, for variables and constants; spaces, in all other cases.) To turn headings off, specify COLUMN HEADING OFF in the DETAIL LINE command.
    LINE nBefore displaying the associated item, the Report Generator is to skip to line n on the current page. The value of n must be greater than the current line number. LINE cannot be used in conjunction with NEWLINE or OLDLINE.
    MASK ‘mask’The Report Generator is to apply the specified mask pattern to the value of the associated item. Masking rules vary for alphanumeric, numeric, and date values.
    NEWLINE [n]Before displaying the associated item, the Report Generator is to skip n lines. The default value for n is 1. NEWLINE cannot be used in conjunction with LINE or OLDLINE. NEWLINE 1 is automatic for the first item in each heading or detail line command. (Use OLDLINE when overstriking is required.)
    NEWPAGE [n]Before displaying the associated item, the Report Generator is to skip to the nth page following the current page. The default value for n is 1.
    NOPRINTThe Report Generator is to omit the display of the associated report item. (This option is useful for using a special expression format to initialize a variable, but not print the variable’s value, for example.)
    OLDLINEBefore displaying the associated item, the Report Generator is to return to the start of the current line (“overstrike”). OLDLINE cannot be used in conjunction with NEWLINE or LINE.
    SPACES nBefore displaying the associated item, the Report Generator is to move n character columns to the right. Zero (0) is a valid value for n. SPACES cannot be used in conjunction with COLUMN.
    SPANThe Report Generator is to display the associated item over one or more lines in a column WIDTH characters wide. When one line is full, display continues on the next line regardless of where the split occurs.
    SUPPRESSThe Report Generator is to omit display of the associated item if its value has not changed since it was last displayed.
    UNDERLINEThe Report Generator is to underline the associated item.
    WIDTH nThe Report Generator is to use n as the output width for the associated item. (Normally, the output width is identical to the defined width of the item or the width of the mask or heading for the item, whichever is greatest. If n is less than the defined width of the item, the value is truncated unless WRAP or SPAN is also specified.
    WRAPThe Report Generator is to display the associated item over one or more lines in a column WIDTH characters wide. An attempt is made to split the item at logical break points (e.g., a blank, a hyphen, an oblique (slash), a comma).
    REPORT FROMThe REPORT FROM command produces a set whose members are used as the source of data values for the report. The various clauses in the REPORT FROM command also specify the overall format of the report and determine if the report is line-oriented or column-oriented.
    REPORT FOOTINGGenerates a line-oriented footing at the very end of the report, regardless of whether the report itself is line-oriented or column-oriented. To generate column-oriented footings, use the BREAK (Reports) command with a constant expression.
    The footing can include individual data values only from the last member of the REPORT FROM set. However, summary data computed over all records in the set (using aggregate functions) can appear in the footing.
    BREAKBreaks can be organized into the hierarchy: 0, 1, 2, and so on. The higher the level number, the more minor the break.
    Each change in the value of expression triggers a break at the associated level. The break levels below it in the hierarchy are also triggered; that is, a level 1 break triggers a level 2 break, and a level 3 break, and so on.
    The report items in the break heading can include individual data values only from the first member of the current group.
    The report items in the break footing can include individual data 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.
    Each time the break level is triggered, headings specified in a corresponding COLUMN BREAK command, DETAIL LINE command, and PAGE HEADING command are also displayed.
    DETAIL LINEThe DETAIL LINE command is executed for every record of the set specified in the REPORT FROM command.
    The column headings for all reportitems specified in the DETAIL LINE command are displayed, subject to any colheadings specification.
    Only one detail line is produced for each record of the report set. If more than one DETAIL LINE command is used in a report specification, the DETAIL LINE command that is executed for a particular record in the report set is the first DETAIL LINE without a WHERE clause, or the first DETAIL LINE whose WHERE clause is true for that record.
    PAGE HEADINGThe PAGE HEADING command causes a heading to be displayed at the top of every page of a report. It also controls the display of break headings at the top of each report page. Report items in this command can include individual data values only from the first record to be processed on the current report page.
    PAGE FOOTINGthe PAGE FOOTING command causes a footing to be displayed at the bottom of every page of a report. Report items in this command can include individual data values only from the last record processed on the current report page; however, summary information computed over all the members on the current report page can be displayed in the footing.
    PAGE RIGHTThe PAGE RIGHT “footing” is placed along the right-hand edge of each page in a column-oriented report. The column of text generated by this command ends in the right-most column of the page. Report items in this command can include individual data values only from the last record processed on the current report page; however, summary information computed over all the members on the current report page (using aggregate functions) can be displayed in the footing.
    PAGE LEFTThe PAGE LEFT command generates a “heading” along the left-hand edge of each page in a column-oriented report. The column of text generated by this command starts in column 1 on the page. Report items in this command can include individual data values only from the first record to be processed on the current report page.
    COLUMN BREAKThe 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.
    PRINT REPORTThe Zim document specified by name must contain a graphical report previously generated by a REPORT FROM command with the GRAPHIC option. The document can be printed any number of times.
    If the destination is the printer, the report is printed automaticaly without operator’s intervention.
    If the destination is the screen, the report can be visualized and then, optionally, printed and/or written to a PDF format file.
    ENDREPORTThe ENDREPORT command is used only in conjunction with a REPORT FROM command. It marks the end of a report.
    When an ENDREPORT is encountered, the current group of report commands is processed. The resulting report is directed to the current output device.

    SET EXCEPTION

    Triggers an exception handler in the absence of an exception condition.

    Syntax

    SET EXCEPTION condition

    Parameters

    condition  Can be BREAK Mimics a terminal or process “break” condition (i.e., the user pressing the “break” key). DEADLOCK Mimics a deadlock in a multi-user system. Does not abort the current transaction. ERROR Mimics an error condition. WARNING Mimics a warning condition.

    Comments

    A SET EXCEPTION command mimics the specified condition, triggering the associated exception handler, if such a handler has been declared (by the ON command). The SET EXCEPTION command cannot be used in the body of an exception handler. The SET EXCEPTION command has no effect on system variables such as $InTransaction, $ErrCode, or $ErrLevel. The SET EXCEPTION command is not affected by the SET RESET and SET RESTORE commands.

    Example

    localprocedure LocProc (inout $Deadlock)
       on deadlock
          let $Deadlock = $true
          return
       endon
       ... other commands ...
    endprocedure
    procedure MainProc ()
       on deadlock
          goto RetryTransaction
       endon
       ... other commands ...
    RetryTransaction:
       transaction
       ... other commands ...
       LocProc ($Deadlock)
       if $Deadlock = $true
          set exception deadlock
       endif
       ... other commands ...
       endtransaction
    endprocedure

    In the preceding example, SET EXCEPTION mimics a DEADLOCK condition, triggering the declared deadlock exception handler in one procedure when the deadlock has actually occurred in another procedure.

    See Also

    ON

    Macros

    macro is a dynamically declared name that represents a character string. When a macro call is encountered in an application program the macro call is replaced by the current character string value of the macroMacros are sometimes called replacement parameters or substitution variables.
    The following topics discuss how to work with macros in applications:

  • Availability of macros
  • How macros acquire values
  • Macro Substitution
  • Macros and Compiled Programs
  • $HelpFile

    The name of the file containing the online help.

    Syntax

    $helpfile

    Return Value

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

    Description

    $HelpFile gives the name of a file containing online help topics.
    Set by the application program to the name of a file containing the online help information. By changing the value of $HelpFile, an application can use different help files at different times during a session. The default help file is ZIM.HLP.
    The file name should include the directory path. The special file path indicator characters can be used.

    Example

    let $helpfile = "c:\myapp\applic.hlp"

    Program Templates and the GENERATE Command

    Although every application has its own unique requirements, the individual components of applications are often very similar. For example, menus, pop-up windows, and data entry forms and displays are common components of most applications. Pop-up windows, for instance, can vary in size, location and contents, but the commands to present them to the application user and to process the result of user interaction are essentially the same. While Zim provides a great deal of flexibility in how applications can be designed and developed, experienced Zim programmers typically develop a programming style for various components of their applications. Consistency of style means that the application program code for one application object can be copied and modified when another, similar object is needed. If a new pop-up window is needed, for example, the object definition and processing code for a similar, existing pop-up can be copied, and the necessary minor changes made. This approach can reduce development time considerably.

    Template Definition

    The template feature for Zim is a formal mechanism for producing reusable program code. A template is an application program that contains the basic code for defining, presenting, and processing an application component such as a standard pop-up window. In addition, the template contains fragments of code that

    • customize the basic code
    • generate the application objects (e.g., windows, forms, variables) needed by the application components

    Template Syntax

    A template is similar to any other application program, in that it contains a series of command statements. However, a template is also different, in that it contains sections of code bounded by special template delimiters: << and >>. The template delimiters are always placed at the start of a line; nothing else should appear on the same line. In this example,

    … commands 1 …

    <<

    … commands 2 …

    >>

    … commands 3 …

    the software handles the command statements that appear between the template delimiters differently depending on if the program is being executed, parsed, or compiled, or if it is being run under the GENERATE command. During normal execution, commands 1 and commands 3 execute normally. Commands 2 are ignored. With the PARSE or COMPILE command, commands 1 and commands 3 are parsed or compiles in the usual manner. Commands 2 are ignored. With the GENERATE command, commands 1 and commands 3 execute normally. Commands 2 are sent as output, after macro substitution, to the current output device.

    Program Call Syntax

    The syntax of the call to the template program in the GENERATE command is identical to the structure of a call to a standard application program of the same type. The rules for passing values to the parameters in a template program containing a formal procedure operate in exactly the same way as for an application program containing a formal procedure.

    Program Execution

    Program execution is handled slightly differently under GENERATE. Execution always proceeds interpretively, even if the template program has been compiled. When the software encounters the << template delimiter alone on a line, execution is suspended, and the subsequent lines are written – after macro substitutions – to the current output destination. Execution resumes when the software encounters the >> template delimiter alone on a line.

    Physical Line Handling

    Normally, each physical line in the template is sent as a separate line to the current output destination. To cause successive physical lines in the template to be joined into one line in the output, end the appropriate lines in the template with the dollar sign ($). At the output destination, the physical line containing the dollar sign and the next physical line appear concatenated on one physical line. If a line must end with a dollar sign for another reason, direct the software to interpret the dollar sign literally by placing a backslash (\ – Escape) preceding the dollar sign.

    How To Use Variables

    A variable is a programming object defined in the Object Dictionary for the application.
    Variables are used to store values temporarily during an application session.
    A variable is assigned a size and a data type in its definition, but until assigned a value during an application session, the variable is valueless (that is, $Null).

    How To Use Value Expressions

    Value expressions represent character or number values.
    A value expression is an expression that, when evaluated, yields either a number or a character string.
    Value expressions are subdivided into

    • atomic expressions
    • arithmetic expressions
    • functional expressions

    A value expression can be very simple, containing only one argument. Such expressions are called atomic expressions. An atomic expression is a value expression that consists solely of
    literals (explicit numbers or character strings)
    permanent object names (constants, global variables, system variables, fields, form fields)
    temporary names (local variables, parameters)
    Value expressions can also be quite complex, containing many arguments combined by means of arithmetic operators (arithmetic expressions), or software functions (functional expressions), or both. Parentheses can be used to explicitly control the order of evaluation in complex value expressions.
    When a statement contains a value expression, the software evaluates the expression and returns the resulting value. Consequently, a value expression can be used almost anywhere that you can use a literal.

    Assigning and Reassigning Values to Atomic Expressions

    An atomic expression is a value expression that consists solely of a literal constant, named constant, variable name (including subscript, if applicable), field name, form field name, or formal parameter name.
    During an application session, an application program can explicitly set and reset the values of certain atomic expressions, specifically: global and local variables, selected system variables, parameters to formal procedures, and macros. The command that explicitly assigns values to these expressions is the LET command.
    Note: To assign values to database fields, you must use an ADD, CHANGE, INSERT, or UPDATE command (which can contain LET as a subcommand).
    The LET command can be used as shown in the following example:
    let var1='abcd' var2=10.5 var3=var4
    The LET command can also make its assignments during the evaluation of a complex value expression that appears within another command statement. The special assignment expression format is created by enclosing the LET command in parentheses.

    How To Use Literal Constants

    A literal constant is a number or character string written directly into an application program.

    Writing Valid Number Constants

    Number constants can consist only of the digits 0 to 9 and a decimal point (if required).
    Number constants are automatically assigned the data type VASTINT and the number of decimal places shown in the number (if any).

    Writing Valid Character Constants

    Character constants can contain any digits, letters, or symbols, including reserved characters and hex codes.
    Character strings should be enclosed in quotation marks (either single or double), but the quotation marks can be omitted if the string contains only digits, letters, dollar signs ($), and underscores (_), and if the string is not identical to a reserved word.

    Examples of Number Literals

    3.14159
    10
    .999

    Examples of Character Literals

    abcde
    "$10.99"
    1234A
    ""

    en_CAEnglish