HP 3000 Manuals

DEFINE [ HP Transact Reference Manual ] MPE/iX 5.0 Documentation


HP Transact Reference Manual

DEFINE 

Specifies definitions of item names, names of MPE V system intrinsics, or
segmented program control labels to be used by the compiler.

Syntax 

DEFINE(modifier) definition-list;

The DEFINE statement is used to define items, entry points into program
segments, or intrinsics called with the PROC statement.  DEFINE
statements are generally the first statements that follow the SYSTEM
statement in a Transact program.

The function of the DEFINE statement depends on the modifier you choose,
and for DEFINE(ITEM) on the particular syntax option.  The allowed
modifiers are:

ENTRY                 Defines a program control label within a segment as
                      global to the entire program.  (See Syntax Option
                      1.)

INTRINSIC             Defines an MPE V system intrinsic to be called by
                      the PROC verb.  (See Syntax Option 2.)

ITEM                  Defines one or more item names.  (See Syntax Option
                      3.)

                      Defines a synonym for an item name.  (See Syntax
                      Option 4.)

                      Defines a marker item, which is a position in the
                      list register.  (See Syntax Option 5.)

                      Defines an item name whose attributes are to be
                      satisfied at execution time.  (See Syntax Option
                      6.)  (Transact/V Only)

The definition-list depends on the modifier, or syntax option, you
choose.

Syntax Options 

(1) DEFINE(ENTRY) label[:label]...;

The ENTRY modifier causes a statement label within a program segment to
be global to the whole program so that statements in any segment can
reference this label.  You need not define entry point labels within the
root segment (segment 0).

(2) DEFINE(INTRINSIC) intrinsic-name[:intrinsic-name]...;

The INTRINSIC modifier defines MPE V system intrinsics that are called by
the PROC verb.  Declaring the intrinsic in this manner causes Transact to
load the intrinsic at system startup.

If you include an intrinsic name that is not recognized by the compiler,
a compile time error message will be issued.  If this occurs, remove the
unrecognized intrinsic from the DEFINE(INTRINSIC) statement.  If the
DEFINE(INTRINSIC) statement is removed, Transact tries to load the
intrinsic when the intrinsic is called with a PROC statement.  Intrinsics
specified with the DEFINE(INTRINSIC) statement are resolved at system
startup from SL.PUB.SYS.

(3) DEFINE(ITEM) item-name [count]
      [type(size[,decimal-length[,storage-length]])]

      [=parent-name[(position)]]
      [,ALIAS=(alias-reference)]
      [,COMPUTE=arithmetic-expression]
      [,EDIT="edit-mask"]
      [,ENTRY="entry-text"]
      [,HEAD="heading-text"]
      [,INIT=[value|(BINARY(value))|(HEX(value))|(OCTAL(value))]
      [,OPT]
      [:item-name...]...;

This option defines an item-name not defined in the data dictionary.  It
can also be used to redefine items already defined in the data
dictionary.  Any number of item-name, separated by colons (:)  can be
specified in a single DEFINE(ITEM) statement.  (See Chapter 3, "Data
Items," for detailed descriptions of data types.)

item-name              The name of a data item or system variable to
                       which the definition applies.

                       When it refers to a data item, item-name 
                       identifies an item that exists in a database or
                       file used by the Transact program or that is to be
                       used as a temporary variable.  This item may or
                       may not be included in the data dictionary.  The
                       first character must be alphanumeric, and the
                       other characters may be alphabetic (A-Z, upper or
                       lowercase), digits (0-9), or any ASCII characters
                       except , ; :  = < > ( ) " or a blank space.  The
                       item-name can be up to 16 characters long.

                       Five system variables can be specified as an
                       item-name:  $CPU, $DATELINE, $PAGE, $TIME, and
                       $TODAY. Note that only the EDIT= and HEAD= options
                       are valid with these variables.

count                  The number of occurrences of the item if it is a
                       sub item within a compound item.  (All of the sub
                       items have the same attributes.)

                       Example:  DEFINE(ITEM) SUB 24 X(30);

                       SUB is defined as a compound item that has 24
                       30-character sub items.

type                   The data type:

                                  X = any ASCII character
                                  U = uppercase alphanumeric string
                                  9 = numeric ASCII string (leading zeros stripped)
                                  Z = zoned decimal (COBOL format)
                                  P = packed decimal (COBOL comp-3)
                                  I = integer number
                                  J = integer number (COBOL comp)
                                  K = logical value (absolute binary)
                                  R = real, or floating point, number
                                  E = real, scientific notation

                       If type is followed by a "+", then the item is
                       unsigned, and can have positive values only.  Data
                       entry values are validated as positive and, if the
                       type is Z or P, positive unsigned value formats
                       are generated.  Items defined as type E are
                       displayed in the format:  n.nnE+nn, but cannot be
                       entered in this format; they may be entered as
                       integer or real numbers.  (See Chapter 3, "Data
                       Items," for detailed descriptions of data types.)

                       _________________________________________________ 

                       NOTE  Transact's "E" item type is different from
                             the TurboIMAGE "E" item type that is defined
                             as IEEE real.

                       _________________________________________________ 

size                   The number of characters in an alphanumeric string
                       or the number of digits, plus decimal point if
                       any, in a numeric field.

                       Transact adds a display character for the sign to
                       the specified size of numeric items (types Z, P,
                       I, J, K, R, and E) unless the item type is defined
                       as positive only with a "+".  You should be aware
                       of this extra display character when transferring
                       data to VPLUS numeric fields.  (See Table 3-3 for
                       the relation between the specified size, its
                       storage allocation, and display requirements.)

                       If both type and size are omitted, the dictionary
                       definition of the item is used.

decimal-length         The number of decimal places in a zoned, packed,
                       integer, or floating point number, if any.  For Z
                       and P types only, the maximum decimal-length is 1
                       less than the maximum storage-length of the item.

storage-length         The byte length of the storage area for the data
                       item, which overrides the length calculated by the
                       compiler from the type, size, and decimal length
                       values.

                       Storage length of X and U type items is limited
                       only by the size of the data register.  The
                       maximum size of the numeric item types 9, Z, P, I,
                       J, and K is 27 digits or characters, unless a
                       decimal is included in which case the maximum size
                       is 28 characters or digits including the decimal
                       point.  For R and E types, the maximum recommended
                       size is 22 characters and digits, to allow for 17
                       accurate digits in the mantissa, a decimal point,
                       the sign of the exponent, the letter E, and 2
                       digits for the exponent.

=parent-name           The name of the parent if you are defining a child
                       item; redefines all or part of a parent item name
                       defined elsewhere in the program or in the
                       dictionary.  (Similar to an equivalence in SPL or
                       FORTRAN.)

                       The following is an example of redefinition of a
                       parent item defined as "NAME".

                                 DEFINE(ITEM) NAME X(32):
                                              FNAME X(10)=NAME(1):
                                              MIDINIT X(1)=NAME(11):
                                              LNAME X(21)=NAME(12);

                       When working with KSAM or MPE files, it is useful
                       to define the record as a parent item and the
                       fields as child items.  (See the example in the
                       description of the SYSTEM verb.)

position               The byte position in the parent item that is the
                       starting position of the child item.  Begin
                       counting at position 1.  The default is 1.

                       In the following example, the child item YEAR
                       starts in position 1 of the parent item DATE,
                       MONTH starts in position 3, and DAY in position 5.

                                 DEFINE(ITEM) DATE X(6):
                                              YEAR X(2)=DATE:
                                              MONTH X(2)=DATE(3):
                                              DAY X(2)=DATE(5);

ALIAS=(alias-          Other names (aliases) by which item-name is known,
reference)             where (alias-reference) has the form:

                            (item-name1 [(file-list1) [,item-name2[(file-list2)]]...])

                       The item defined as item-name is called item-name1 
                       in any of the files or data sets in file-list1,
                       item-name2 in any of the files in file-list2, and
                       so forth.  If file-list1 is omitted, item-name1 is
                       the only alias-reference allowed.  A file list may
                       consist of file or data set names separated by
                       commas.  If a referenced data set is not in
                       the home base specified in the SYSTEM
                       statement, the base name must be specified as
                       set-name(base-name).

                       Note that Transact does not retrieve alias
                       definitions from the dictionary.  You must define
                       any aliases in a DEFINE(ITEM) statement in your
                       program.

                       An alias ensures that when you reference item-name 
                       in your program, this name is associated with the
                       other names by which the item is known in files or
                       data sets.  You always reference such an item by
                       its primary name, not its alias.

                       The following example defines the item QTY-ORD,
                       which is known in the file ORDERS as QUANTITY and
                       in the file ORD-MAST as QUANT-ORD. Note that all
                       aliases must have the same storage length as the
                       data item value referenced in the data set or
                       file.

                                 <<Use name QTY-ORD in program>>
                                 DEFINE(ITEM) QTY-ORD I(4), ALIAS=(QUANTITY(ORDERS),
                                    QUANT-ORD(ORD-MAST));

COMPUTE= arithmetic-      An arithmetic expression that specifies the
expression                computation to be performed before the item is
                          used in a DISPLAY, OUTPUT, or LET statement.
                          It may contain two or more variables separated
                          by one or more arithmetic operators.  Use the
                          form shown for the LET statement.

EDIT="edit-string"        Default edit mask used for the item's value in
                          any display.  (See the DISPLAY and FORMAT
                          statements for a description of the edit mask
                          feature.)  When a numeric value to be printed
                          is too large for the edit mask, a series of
                          pound signs (#) are printed in place of the
                          value, to indicate an overflow.

ENTRY="entry-text"        Text string used as the default prompt string
                          for the item when used by the PROMPT and DATA
                          statements.

HEAD="heading-text"       Text string used as the default heading for the
                          item in any display function.

INIT=[value]              Initial value moved into the item each time it
                          is added to the list register.  The INIT
                          parameter on the LIST verb overrides this
                          parameter.  If this parameter appears without a
                          value, the item is initialized to zero for
                          numeric or blank for ASCII, eliminating the
                          need to use the INIT parameter with the LIST
                          verb.  For example:

                               DEFINE(ITEM) CODE I(3), INIT=999;
                               DEFINE(ITEM) QUANTITY I(3), INIT=;

                          The INIT= option works similarly to the LET
                          verb.  If an array is being initialized, each
                          element in the array is initialized to value.

                          This option also allows initialization of I, J,
                          and K types in terms of a binary, octal, or
                          hexadecimal base.  The number specified is
                          treated as a signed, 32-bit number.  Enough
                          storage must be allocated to hold the specified
                          number.

                          The following examples illustrate the use of
                          this option.

                          The first example defines an initial value of
                          -1.  Two bytes of storage are sufficient.

                                    DEFINE(ITEM) OCT1 I(5,,2), INIT=(OCTAL(377777777777));

                          The second example defines an initial value of
                          -2.  Two bytes of storage are sufficient.

                               DEFINE(ITEM) OCT2 I(5,,2), INIT=(OCTAL(377777777776));

                          The third example defines an initial value of
                          65535.  Two bytes of storage are not sufficient
                          so four bytes must be allocated.

                               DEFINE(ITEM) HEX1 I(5,,4), INIT=(HEX(ffff));

                          The fourth example defines an initial value of
                          -32768.  Two bytes of storage are not
                          sufficient so four bytes must be allocated.

                               DEFINE(ITEM) HEX2 I(5,,4), INIT=(HEX(ffff8000));

                          The last example defines an initial value of
                          2147483647, the maximum possible using a
                          binary, octal, or hexadecimal base.  Eight
                          bytes of storage are required.

                               DEFINE(ITEM) HEX3 I(10,,8), INIT=(HEX(7fffffff));

                          The INIT= option cannot be used for child
                          items.

                          ______________________________________________ 

                          NOTE  Initializing a positive type with a
                                negative value results in a run-time
                                error.

                          ______________________________________________ 

OPT                       OPT is used in combination with the compiler
                          control option, OPT@, OPTE, OPTH, OPTI, and
                          OPTP. When OPT is specified for an item, the
                          compiler does not store the item's textual name
                          in the p-code file if the OPTI control option
                          has been specified.  OPT, used in conjunction
                          with the above compiler control options, saves
                          data segment stack space at execution time.
                          (See Chapter 9 for a discussion of the OPT@,
                          OPTE, OPTH, OPTI, and OPTP compiler options.)

                          It is your responsibility to ensure that the
                          item's textual name is not required within the
                          program.  An item name is needed for a prompt
                          string, display item heading, or for the LIST=
                          option of verbs that access a database.

(4) DEFINE(ITEM) item-name=item-name1 

This option defines a synonym for an item defined elsewhere in the
program or in the dictionary.  Other item attributes may not be defined
using this syntax option.

item-name             A synonym for item-name1 where item-name1 is
                      defined elsewhere in the program or in the
                      dictionary.  item-name assumes the definition of
                      item-name1, but Transact always references
                      item-name1 in any file or data set operation.

                      Use this option to provide an alternate name for an
                      item.  The synonym item-name exists only while the
                      program executes; it is not an item name in a file
                      or data set, or the dictionary.  For example:

                              DEFINE(ITEM) PROD-NO 9(10):
                                           PRODUCT-NUM=PROD-NO;

                      This statement defines the item PROD-NO as a type 9
                      10-digit item, and defines PRODUCT-NUM as a synonym
                      for PROD-NO. The same item can now be called either
                      PRODUCT-NUM or PROD-NO within the program.

(5) DEFINE(ITEM) item-name @[:item-name @]...;

This option defines a marker item.  A marker item marks a point in the
list register, but it reserves no space in the data register.  The marker
item must be defined with the DEFINE(ITEM) statement and placed in the
list register with the LIST statement.

A marker item can be referenced by list pointer operations and list range
options.  Marker items are useful in conjunction with the SET modifier on
the PROMPT verb.  The PROMPT(SET) statement causes the contents of the
list register to be defined at execution time.

The following sequence of Transact statements shows an appropriate use of
the marker item:

        DEFINE(ITEM) MARKER1 @: MARKER2 @;
        LIST MARKER1;
        PROMPT(SET) EMPL:DEPT:PHONE:ROOM:LOCATION;
        LIST MARKER2;
        UPDATE EMPLOYEES,LIST=(MARKER1:MARKER2);

The first statement defines MARKER1 and MARKER2.  The second statement
assigns space in the list register to MARKER1.  The third statement
prompts for new information about employees.  It is not known which and
how much information will be entered.  When data entry is complete, a
second marker is assigned in the list register.  Then the EMPLOYEES file
is updated with all the information in the list and data registers
between MARKER1 and MARKER2.  (This example assumes that the current
entry has been set up appropriately by a previous get of the EMPLOYEES
data set.)

You might know only the start and end positions of the data entered, but
not how many entries will be made.  By placing marker items in the list
register using the LIST statement, you are able to pass a variable number
of items to the EMPLOYEES file.

(6) DEFINE(ITEM) item-name *[:item-name *]...;

This option defines an item name whose attributes should be satisfied at
execution time rather than by the compiler at compile time.  Note that
only the basic attributes can be resolved at execution time; these are
count, type, size, decimal-length, and storage length, not such secondary
attributes as heading text or entry text.


NOTE This format is not valid in Transact/iX.
Examples The following example shows how to define a key item (called KEY) for KSAM file access, assuming the key is a 10-character item starting in byte 3 of an 80-character record. DEFINE(ITEM) RECORD X(80): DEL-CODE I(2) = RECORD(1): KEY X(10)= RECORD(3); MOVE (KEY) = "A123456789"; <<Assign value to key >> SET(KEY) LIST(KEY); <<Use key value to find chain head>> FIND(CHAIN) KFILE, LIST=(RECORD); <<Read entire record >> In another example, a portion of a key is defined as a "generic key": DEFINE(ITEM) RECORD X(80): DEL-CODE I(2) = RECORD(1): KEY X(10) = RECORD(3): GEN-KEY X(2) = RECORD(3); The key search is similar to that shown above; use the generic key (GEN-KEY) value to locate all records with key values starting with the same first two characters.


MPE/iX 5.0 Documentation