% DECLARE

Define a % DECLARE table made of variable assignments that can be referenced either directly (after assigning values to its subscripts), or by searching with the % LOOKUP structure.
Restriction: This topic applies only when the AppMaster Builder AddPack has been installed, and applies only to Windows platforms.

Syntax:

 % DECLARE 
&fieldname(&subscript1)[...(&subscriptN)]  
   [% &declarepart1      [Xn|Nn|REDEFINES]
                .
                .
                .
    % &declarepartN       [Xn|Nn|REDEFINES]]
[% END]

Parameters:

&declarepart Subscript-part of &fieldname. Indentation indicates subordination. Note the following.
  • Do not use an &declarepart as a &subscript.
  • If an alphanumeric or numeric picture clause (Xn or Nn) assigns a fixed length to a &declarepart, and &fieldname has more than one &declarepart, each &declarepart needs a picture clause.
  • The maximum &declareparts sum in one DECLARE structure level is 78 bytes
  • The maximum number of &declareparts per table is 1000.
&fieldname Name-assignment statement with zero or more subscripts and up to 78 &declareparts in each structure level.
&subscript Set members of single- or multi-dimensional arrays. Values are numbers or strings (maximum 12 characters). For numeric values, the counter starts at 1 and increments until the end of the numeric value. There is no limit on the number of &subscripts.

Comments:

  • Assign at least one &declarepart of each &fieldname a value in order to reference other &declareparts for the same &fieldname.
  • Values of &declareparts can be changed by conventional AMB variable assignment statements.
  • &Declareparts can be accessed in the same manner as any other variable except when accessed by the following functions: &INDEX, &LENGTH, &NUMERIC, &PARSE, &SUBSTR.
  • &Declareparts can be redefined with REDEFINES or REDEF. REDEFINES indicates that it shares the same DECLARE storage as the &declarepart immediately preceding it at the same level of indentation.
  • You can REDEFINE a REDEFINED table.
  • &Subscripts can be passed as actual arguments to a rule.
  • The maximum number of % DECLARE tables per program is 200.

Examples:

Although &subscript &KEY has already been set to several values, the most common value is 1. The current values of &FILE and &KEY determine &FILE-KEY-NAME, whereas &FILE-KEY-NAME always references key 1, regardless of the &KEY value.

% DECLARE &(&FILE)-KEY-(&KEY)-A
    % &FILE-KEY-NAME        X30
    % &FILE-KEY-TYPE        X
    % &FILE-KEY-LEN         N4
% DECLARE &(&FILE)-KEY-1-A
    % &FILE-KEY-1-NAME      X30
    % &FILE-KEY-1-TYPE      X
    % &FILE-KEY-1-LEN       N4
           .
           .
           .

Access fixed-length strings of screen field attribute records that are stored in the SCRSYMB file.

% DECLARE &(&SCX-SCR)-XFLD-(&SCX-FLD)
    % &SCP-FLD-NAME                   X16
    % &SCP-REP-CNT                    N3
    % &SCP-REP-COL                    N3
    % &SCP-FLD-SHORT                  X8
    % &SCP-FLD-FI
        % &SCP-FLD-LEN                N3
        % &SCP-FLD-ROW                N3
        % &SCP-FLD-COL                N3
        % &SCP-FLD-ATTRS
            % &SCP-FLD-PROT           X
            % &SCP-FLD-INTENS-FLG     X
            % &SCP-FLD-MDT-FLG        X
            % &SCP-FLD-NUM-FLG        X
        % &SCP-FLD-EXT-ATTRS
            % &SCP-FLD-RVID-FLG       X
            % &SCP-FLD-BLINK-FLG      X
            % &SCP-FLD-UNDER-FLG      X
            % &SCP-FLD-COLOR          X2
            % &SCP-FLD-DET-FLG        X
    % &SCP-FLD-EDIT-FLG               N
    % &SCP-FLD-IM-MOD                 X

The above % DECLARE statement accommodates these fixed-length record strings stored in SCRSYMB.

% &DMOL-XFLD-1 = "PART-NBR   0 08  8  6 19UNTFFFF  F1F"
% &DMOL-XFLD-2 = "SHORT-DESC 0 0  13  8 19PNTFFFF  F0F"
% &DMOL-XFLD-3 = "LOCATION   5 3  12 12  5PNTFFFF  F0F"
           .
           .
           .

Directly reference a DECLARE table.

% DECLARE &VS-(&VSX-FILE)-KEY-(&VSX-KEY)-B
    % &VSP-FILE-KEY-VOL                X8
    % &VSP-FILE-KEY-SPACE              X20
    % &VSP-FILE-KEY-CICZ               X20
           .
           .
           .
% &VSX-FILE = "FILE3"
% &VSX-KEY = 2
           .
           .
           .
% &VOL = &VSP-FILE-KEY-VOL

Reference a DECLARE table with % LOOKUP.

% DECLARE &IMS-PCB-(&PCBX)-SEG-(&SEGX)
    % &IMS-PCB-SEG-NAME                 X30
    % &IMS-PCB-SEG-IMSNAME              X8
    % &IMS-PCB-SEG-PROCOPTS
        % &IMS-PCB-SEG-PROCOPT-GET      N
        % &IMS-PCB-SEG-PROCOPT-ISRT     N
        % &IMS-PCB-SEG-PROCOPT-REPL     N
        % &IMS-PCB-SEG-PROCOPT-DLET     N
    % &IMS-PCB-SEG-LEN                  N6
           .
           .
           .
% LOOKUP &IMS-PCB-SEG-NAME = &THE-SEG-NAME-YOU-WANT FROM 1 1
           .
           .
           .
% ELSE
           .
           .
           .

Reference a loaded table by coding a table of value assignments; use % DECLARE to name the table and define &subs for the table name.

% DECLARE &OPERATOR-(&OPR)
    % &OPERATOR            X2
    % &OPERATOR-SYMBOL     X
% &OPERATOR-1 = "EQ="
% &OPERATOR-2 = "LT<"
% &OPERATOR-3 = "GT>"
% &OPERATOR-4 = "MI-"
% &OPERATOR-5 = "PL+"
% &OPERATOR-6 = "TIX"
% &OPERATOR-7 = "DI/"

Load a table of value assignments by varying the &subs of a % DECLARE.

% DECLARE &VS-OPT-(&VSX-OPT)
    % &VS-FILE-OPT
% REPEAT VARYING &VSX-OPT FROM 1
% WHILE &DEFINED(&SCR-OPTS-<&VSX-OPT>)
    % &VS-FILE-OPT = &DEFVAL