HP 3000 Manuals

Compiler Commands [ HP Transact Documentation Update Notice ] MPE/iX 5.5 Documentation


HP Transact Documentation Update Notice

Compiler Commands 

You can place any of the following commands between any two statements in
the source program to control the compiled output, to conditionally
compile blocks or code, or to control which data dictionary is used.
Because these commands are not language statements, do not terminate them
with a semicolon.

Compiler Output Commands 

!COPYRIGHT          Causes the compiler to place the specified
("text-string")     text-string in the first record of the code file as a
                    copyright notice.  The text-string can be up to 500
                    characters long.  This command can only be specified
                    once; usually, it should follow the SYSTEM statement.
                    [REV BEG]

!INCLUDE(file-      Causes the compiler to include the Transact
name)               statements from a specified source file (file-name)
                    that is not the source file being compiled.[REV END]
                    The file-name statements are included at the point in
                    the listing where !INCLUDE appears and are compiled
                    with the main source file.  The file-name can be a
                    fully qualified name with file group and account.  Up
                    to 5 files can be nested with !INCLUDE commands.

!LIST               Writes subsequent source statements to the list file.
                    If LIST is specified in response to the CONTROL>
                    prompt, !LIST has no effect.

!NOLIST             Suppresses the listing of subsequent source
                    statements.  If NOLIST is specified in response to
                    the CONTROL> prompt, !NOLIST has no effect.

!PAGE               Causes the compiler to skip to the top of the next
                    page on the listing.
                    [REV BEG]

!PRECISION          The value of decimal-places determines the minimum
([decimal-places])  number of decimal places (i.e.  digits to the right
                    of the decimal point) that is maintained for all 
                    packed-decimal intermediate results when calculating
                    the value of an arithmetic expression.  This value is
                    used only if an expression's "default" evaluation
                    method would have maintained fewer decimal places.
                    If decimal-places is not included within the
                    parentheses, the decimal precision is reset to the
                    "default" evaluation method.

                    The discussion of decimal precision later in this
                    chapter provides additional information about using
                    this command.  Also see the discussion of rounding
                    when using packed-decimal arithmetic under the LET
                    verb in Chapter 8.[REV END]

!SEGMENT            Causes the compiler to segment the program and the
[("text-string")]   resulting code file at this point in the source file.
                    The compiler displays the specified text-string on
                    TRANOUT when it processes the !SEGMENT command.  The
                    text string can be up to 500 characters long.  The
                    discussion of segmentation later in this chapter
                    tells why and how to segment programs.

Conditional Compilation Commands 

There are 10 conditional compilation switches that can be set to ON or
OFF by the !SET compiler command.  The switches can then be queried by
the !IF compiler command, and compilation of the following block of code
will depend on the value of the switch.  The end of the conditional block
is marked by !ELSE or !ENDIF.

The following compiler commands are used to control conditional
compilation:

                      [REV BEG]

!SET Xn={ON/OFF}    Sets the compilation switch to ON or OFF. The default
                    is OFF. Xn is any member of the set X0, X1, X2, X3,
                    X4, X5, X6, X7, X8, and X9.[REV END]

!IF Xn={ON/OFF}     Queries the named switch to determine its value.  If
                    the condition is true, the following block of code is
                    compiled.  If the condition is false, the following
                    block is not compiled and control passes to the next
                    !ELSE or !ENDIF.

!ELSE               Marks the beginning of a block of code that will or
                    will not be compiled, depending on the condition of
                    the preceding !IF. If the condition is false, the
                    following code is compiled.  If the condition is
                    true, the following code is not compiled.  This
                    optional command allows you to define an "either-or"
                    situation, in which either one block of code or
                    another is compiled, depending on the value of a
                    switch.

!ENDIF              Terminates the influence of an !IF. This command is
                    required if an !IF is used.

Other compiler commands can occur between !IF and !ELSE or !ENDIF.

For example,

     !SET X1=ON
      :
     !IF X1=ON
     DISPLAY "THIS LITERAL WILL BE DISPLAYED BECAUSE X1 IS ON";
     !SET X2=OFF
     !ELSE
     DISPLAY "THIS LITERAL WILL BE DISPLAYED IF X1 IS OFF";
     !ENDIF

Besides switches X0-X9, there is an eleventh switch, XL. It is set to OFF
automatically when code is compiled with Transact/V and to ON when code
is compiled with Transact/iX. You can test this switch with the !IF
command to control compilation.  For example:

     !IF XL=ON
        SYSTEM MYPROG,             << Compile these lines if using Transact/iX. >>
           BASE=MYBASE(,,,HP3000_16),
           FILE=MYFILE((HP3000_16));

     !ELSE
        SYSTEM MYPROG,             << Compile these lines if using Transact/V.  >>
           BASE=MYBASE,
           FILE=MYFILE;

     !ENDIF

System Dictionary Compiler Commands 

The default data dictionary used by Transact is Dictionary/V. If you want
to access System Dictionary, use the following compiler commands:

!SYSDIC[(dictionary.group.Causes the compiler to use the named System
account)]                 Dictionary to resolve all forms files, forms,
                          file definitions, and data items not defined in
                          DEFINE statements.  Defaults to SYSDIC in logon
                          group and account.  If System Dictionary is to
                          be used, this command is required and it must
                          be the first System Dictionary command included
                          in the program.

!NOSYSDIC                 Ends access to System Dictionary and returns to
                          Dictionary/V.

!DOMAIN[(domain)]         Names the System Dictionary domain to be used.
                          Defaults to common domain.

!VERSIONSTATUS[(P/T/A)]   Refers to the version to be used (production,
                          test, or archive).  Defaults to P (production
                          version).

!VERSION[(version)]       Names the version to be used.  Defaults to
                          production version.  This parameter overrides
                          the VERSIONSTATUS parameter.

!SCOPE[(scope[,           Names the scope and the password to be used.
"password"])]             Defaults to DA scope and prompting for the
                          password.

You can change System Dictionary, DOMAIN, VERSIONSTATUS, VERSION, or
SCOPE in the middle of compilation by reissuing the appropriate compiler
commands in the Transact source.  System Dictionary compiler commands can
go between statements and even within one statement--the SYSTEM statement
(see example below).  All of the System Dictionary commands that are used
to effect a single change should appear contiguously.  Comments should
precede or follow the entire group of commands.

The command !NOSYSDIC causes the compiler to end access to the System
Dictionary and return to using Dictionary/V for any following data items
not defined in the program.

For example, if you want to change domains while extracting forms-file
definitions, you can embed compiler commands in the SYSTEM statement as
follows:

     !SYSDIC(SYSDIC.PUB.SYS)[REV BEG]
     !SCOPE(Transact,"password")[REV END]
     SYSTEM APPL1, VPLS = FORMF1,FORMF2,        <--uses common domain 
     !DOMAIN(TEST)
                          FORMF3,               <--uses test domain 
     !NOSYSDIC
                          FORMF4;               <--uses Dictionary/V 

Controlling Decimal Precision 

The !PRECISION compiler command is used to force a minimum number of
decimal places (i.e.  digits to the right of the decimal point) that will
be maintained for all packed-decimal intermediate results when
calculating the value of an arithmetic expression.  This value is used
only if the "default" evaluation method of an expression would have
maintained fewer decimal places.  See the discussion of rounding when
using packed-decimal arithmetic under the LET verb in Chapter 8.

The !PRECISION compiler command in effect at the end of a compiled
program will be used for controlling the decimal precision used
throughout the entire program.  A warning is issued for each additional
!PRECISION compiler command after the first in a source file indicating
that the decimal precision is being changed.  At the end of the compile,
a message is issued if the "default" decimal precision is not in effect.

If a subprogram is called, the decimal precision with which that
subprogram was compiled will apply while it is executing.  Upon return to
the calling program, the decimal precision is reset to the calling
program's decimal precision.

A total of 27 digits are maintained for numbers in packed-decimal format
(whole and decimal parts).  Care should be taken not to request too many
digits of decimal precision.  The result of a multiplication temporarily
uses at least double the number of decimal digits before any rounding
takes place.  If enough digits are not available for the whole number
portion of the value, an overflow condition occurs.

Use any of the following methods as a guide for taking advantage of the
!PRECISION compiler option.

   *   The simplest method is to select a small number (2 to 6), which
       should ensure reasonable decimal precision in the types of
       calculations used in the program.  This should be sufficient for
       the majority of programs.

   *   A more precise method is to set the minimum decimal precision to
       at least one more than the maximum number of digits defined to the
       right of the decimal point for all the items and constants used in
       the program.  You can refine this method by reviewing arithmetic
       expressions throughout the program.

   *   To take full advantage of the decimal precision available, use the
       following steps:

          1.  Determine the maximum number of digits to the left of the
              decimal point that might be stored internally for any 
              intermediate value created using packed-decimal arithmetic.
              For example, if you multiply three values together that
              have the following maximum values:  99, 999.9, and 9999,
              then the maximum number of digits (to the left of the
              decimal point) that the result stores is 9 (= 2 + 3 + 4).
              This value is referred to as LEFT.

          2.  Then the maximum decimal precision that the program allows
              is the result of the following equation:

         (27 - LEFT) / 2            (discard any remainder)


NOTE Regardless of the method you use, test the recompiled program for the possibility of overflow conditions.


MPE/iX 5.5 Documentation