Logo
Back

◆ FLEX has ODTSequences!

8th March 2006

FLEX Utility now has a major functionality change in the way that REPORT Opal scripts can be defined. REPORTS were intended to generate simple or complex strings for file, print or screen output, and are identical to SUPERVISOR DISPLay programs.

This behaviour has changed; FLEX will now permit REPORTS to be, alternatively composed into OPAL blocks, similar to SUPERVISOR ODTSequences, so that they can use statements. The use of blocks is controlled by the key word BEGIN and is permitted for normal REPORTs, HEAD and FOOT.

   -- REPORT ---+----------+--+----------- <Opal string> --------+---|
                |          |  |                                  |
                +-- FOOT --+  +-- BEGIN -- <Opal block> -- END --+
                |          |
                +-- HEAD --+

The definition of an <OPAL block> is identical to that of ODTSEQUENCE in SUPERVISOR. The usual OPAL block constructs such as BEGIN, END, IF, THEN, WHILE, DO, and CASE are all available.

The use of BEGIN to create OPAL blocks is currently mandatory. Due to the complexities of OPAL variable assignments, it is not yet possible to unconditionally create OPAL block code for the traditional OPAL string scripts.

As with ODTSEQUENCEs, statements in an <OPAL block> must be terminated by a semi-colon (;).

New OPAL statements, some familiar to SUPERVISOR users, are now permitted from a REPORT BEGIN block; these include the following:

   ----+--- DISPLAY --+------- ( <OPAL string> )-------------------|
       |              |
       +--- ODT ------+
       |              |
       +--- SHOW -----+
       |              |
       +--- WFL ------+

The ODT, DISPLAY and SHOW statements are identical to their SUPERVISOR equivalents. SHOW displays string contents back to the originating station; the DISPLAY command forces a display message of the string to be generated. ODT passes the string contents ot the MCP using the DCKEYIN function; it is only available to Privileged or SecAdmin
usercodes.

The WFL statement allows WFL-only commands to be locally processed (i.e using the current session attributes such as USERCODE and FAMILY) and, when associated with a REPORT, will act on each file returned by a SELECT. Because of this, the WFL statement should be used with care.

PRINT has not been implemented as printing behaviour is controlled with, the usual FLEX options and command modifiers. If OP+PRINT is set or the :PR modifier is used, all SHOW statements will be printed.

In addition, several SUPERVISOR-only OPAL functions are now available ,for use in FLEX. These include the KEYIN and MAIL functions which function identically to the SUPERVISOR variants.

Some examples: the simple report 'REP TITLE' is identical to:

REP BEGIN\
SHOW(TITLE);\
END;

To REMOVE files as they are reported using the WFL function:

SELECT DAYS(TODAY,CREATEDAY) Gtr 7
REPORT BEGIN\
WFL("REMOVE ",FILENAME); % acts on current file\
END;

Variables are fully supported in REPORT BEGIN blocks; assignments are permitted as statements as in SUPERVISOR and string or real values stored by assignments are not passed back to FLEX for display.

To analyze the contents of the selected file, searching for a target string:

SELECT SYMBOLFILE
REPORT BEGIN
          $T:= TITLE;\
          $TEXT:= $$T.READ(NOSEQ); % Read file without seq num\
          While $LINE:=$TEXT.SPLIT(/) Neq Empty Do\
            If $LINE Eqw "=SEARCHTEXT=" Then\
            Begin\
               SHOW("Text found in ",$T);\
               SHOW($LINE);\
            End;\
        End;
FILES MYFILES/= ON =:FL

The above script is a very simple example of a CANDE FIND, operating on ,the selected MYFILES directory on all pack families.

To email a selected file as an attachment from a FLEX DO:

REPORT BEGIN\
$TEXT:="^ATTACH "&TITLE;\
If #RES:=MAIL("To:support@metalog.com;Subj:Req File",\
$TEXT) Lss 0 And #RES Neq -999 Then\
SHOW("Mail failure: ",#RES);\
END

Both REP HEAD and REP FOOT can use OPAL blocks in the same way. Existing FLEX DO files and FAMILTYMANAGER rules are unaffected by this change. Note that the FAMILYMANAGER rules mechanisms will not be enhanced to use this new feature.