When a panel is designed, the location and layout of input and output fields within it is normally fixed when the panel is created using Edit Services. This means the field characters that define the location of fields (by default %, +, or _), are positioned as required and remain fixed. It is the data or variables within those fields that then change.
However, under some circumstances, you might need to dynamically alter the attributes of fields, or to add or delete entire fields. For example, you might want the color and highlighting for a field to change depending on the data content. (This might be necessary if you are designing a panel that monitors network status, where you want to vary the color of a field to alert an operator).
Some scope for doing this exists by supplying variable data for use on #FLD statements where the variable data is used to alter the characteristics of the field. However, the actual addition or deletion of fields cannot be achieved using this technique and it becomes cumbersome if the attributes of many fields must be altered.
Panel Services lets you dynamically create panel definitions by using a preparsing concept. Preparsing is requested by the #OPT panel statement PREPARSE operand, and makes a preliminary scan of the required panel lines before building the panel.
During this preliminary phase, field characters are ignored and substitution used to change a panel line in any way you require. Only after preparsing is complete, is the normal panel building process performed.
Substitution normally uses the occurrence of ampersand (&) to indicate the start of a variable string. These strings can be resolved to reflect the content of the variable, as set by the procedure before the &PANEL statement.
The PREPARSE operand has the following format:
#OPT PREPARSE=($,S)
#OPT PREPARSE=(!,D)
The first character in the parentheses defines the alternative substitution character (other than an &) to be used during the PREPARSE operation.
The second character specifies the alignment option for the display fields affected by PREPARSE substitution. These options (for Dynamic and Static preparsing) are explained in the following sections.
The alternative substitution character (for example, a dollar sign) is used as the substitution character for the preparse stage of processing. The panel line is scanned for occurrences of the preparse character and the variables are isolated. The variables are then resolved using the values of the corresponding variables set from the procedure. Using an alternative substitution character allows panels to contain a mix of conventional and preparse fields.
Before displaying this panel (see the following sample, which shows the panel before PREPARSE substitution), the procedure tests the values in the variables &FIELD2 and &FIELD3 and appends the appropriate field character to display the field. In this example, using the > character displays the field in red and reverse video, but using the ? character displays the field in yellow without any other highlighting.
#OPT PREPARSE=($,d) INWAIT=60 #FLD > COLOR=RED HLIGHT=REVERSE TYPE=OUTPUT #FLD ? COLOR=YELLOW TYPE=OUTPUT %-------------------- Network Monitor -------------------------- +$FIELD1 +NETWORK STATUS AS AT &TIME ON &DATE3 +NCP1 is currently ............$FIELD2 +NCP2 is currently ............$FIELD3
In this example, FIELD2 and FIELD3 are output fields. FIELD1 is an output field too, by default, but the logic below also converts the FIELD1 position to an input command line if the user ID happens to be USER01. The value assigned to FIELD1 actually contains the new field characters that are to be substituted into the panel definition. The preparse function then builds the new fields before the panel is displayed, so that an input field appears on the terminal.
The following logic shows this procedure:
&IF &STATUS2 EQ INACT &THEN &FIELD2 = >&STATUS2
&ELSE &FIELD2 = ?&STATUS2
&IF &STATUS3 EQ INACT &THEN &FIELD3 = >&STATUS3
&ELSE &FIELD3 = ?&STATUS3
&IF &USERID = USER01 &THEN &FIELD1 = &STR Command +
%===>_COMMAND
&PANEL MYPANEL
Note: Although the variables on the panel start with the preparse substitution character ($), they are still referred to in the NCL procedure as starting with an ampersand.
Preparsing is regarded as a completely separate substitution phase. Therefore, if a preparse character other than an & is designated, this process can substitute data that includes other variables, which are resolved when the standard substitution process for each field is performed. The following sample show a panel after PREPARSE substitution.
#OPT PREPARSE=($,D) INWAIT=60 #FLD > COLOR=RED HLIGHT=REVERSE #FLD ? COLOR=YELLOW %-------------------- Network Monitor -------------------------- +Command %===>_COMMAND +NETWORK STATUS AS AT &TIME ON &DATE3 +NCP1 is currently ............>INACT +NCP2 is currently ............?ACT
| Copyright © 2011 CA. All rights reserved. | Tell Technical Publications how we can improve this information |