23. Formatted screens
The following document is a brief description of the new Formatted Screen (FSS) feature. It allows to set up simple screen definitions within a BREXX script.
For detail take a closer look at the FSS samples in the delivered Installation library BREXX.V2R5M1.SAMPLES
23.1. Delivered Samples
The relevant FSS samples are prefixed with the #-sign:
Member |
Description |
|---|---|
#TSOAPPL |
Shows in a detailed usage of all FSS functions how to set up a menu and “paint” a TK4 like design |
#BROWSE |
A pre-packed FSS application to display data in a List Buffer instead of using SAYs |
#FSS1COL |
A pre-packed FSS application to generate input requests (in one column) |
#FSS2COL |
A pre-packed FSS application to generate input requests (distributes in two columns) |
#FSS3COL |
A pre-packed FSS application to generate input requests (distributes in three columns) |
#FSS4COL |
A pre-packed FSS application to generate input requests (distributes in four columns) |
#FSS4CLX |
A pre-packed FSS application to generate input requests (distributes in four columns) |
23.2. FSS Limitation
The FSS screen limitation has been dropped. Now large screen widths and heights are supported.
FSS supports just one FSS Screen definition at a time. If you need to display more than one FSS Screen in your REXX application, you must close the first and set up and display the next FSS definition. Using this method, you can easily switch between different FSS Screens. It is a good idea to separate the FSS definitions in different sub-procedures; this allows their display by calling it.
23.3. FSS Function Overview
To use FSS functions in BREXX, you must import the FSS API library from BREXX.RXLIB, address and initialise it by a call to FSSINIT, be aware that FSS is a host command application that requires an ADRESS FSS command, it is sufficient to use it once at the beginning. From this time on all host, commands are directed to FSS. If it happens to be and you have to switch to another host API (e.g. ADDRESS TSO or ADDRESS SYSTEM), you can do so, but you must make sure to switch back to the FSS API by re-issuing an ADDRESS FSS command:
1/* IMPORT THE API LIBRARY */
2CALL IMPORT FSSAPI
3/* ADDRESS THE FSS SUBSYSTEM */
4ADDRESS FSS
5/* SWITCH TO FULL-SCREEN MODE */
6CALL FSSINIT
23.3.1. FSSINIT Inits the FSS subsystem
Initialise the FSS environment; this must be performed before any other FSS call: CALL FSSINIT
23.3.2. Principles of Defining Formatted Screens
You can define your formatted screen by using a series of FSSTEXT and FSSFIELD and/or some wrapped FSS functions as FSSMESSAGE, FSSCOMMAND, etc. in your REXX script. Essential parameters are, in all cases, the ROW and COLUMN positions. Be aware that consistency validations are very basic and not bulletproof at all. It is, for example, possible to accidentally re-use occupied ranges, which may lead to unwanted behaviour or results. Performing just necessary validations increases the performance of the screen handling. It is, therefore, essential that you carefully design your Formatted Screens.
23.3.3. FSSTEXT
- CALL FSSTEXT 'text',row,column,[text-length],attributes
Display a text field
- Parameters
text – text to be displayed in the screen
row – row where text should be placed
column – column where text should be placed.
text-length – length occupied by the text, this is an optional parameter; it defaults to the text length.
attributes – screen attributes, like colours, protected, high-lighted etc. For details refer to the attributes section
23.3.4. FSSFIELD
- CALL FSSFIELD 'field',row,column,[length],attributes[,init-value]
Display an input field and associate it with a BREXX Variable
- Parameters
field – field-name of an input area to be displayed on the screen
row – row where text should be placed
column – column where text should be placed.
length – length occupied by the text, this is an optional parameter; it defaults to the text length.
attributes – screen attributes, like colours, protected, high-lighted etc. For details refer to the attributes section
init-value – what should be displayed as content of the input field. It defaults to blank.
Note
Important Notice on the Column Position
Each text or field definition starts with the defined attribute byte, which itself is invisible but tells how the text or field appears on the screen. Therefore the original text or field-definition start at column+1.
Note
Important Notice on Screen Definitions
Be aware that all definitions provided by FSSTEXT and FSSFIELD are stacked internally. They do not create a formatted screen on the fly.
23.3.5. Attribute Definition
The attribute definitions trigger the behaviour or colours of the Formatted Screen text or input elements.
Attribute |
Description |
|---|---|
#PROT |
Definition is protected (default for fsstext) |
#NUM |
input field must be numeric |
#HI |
text is displayed high-lighted |
#NON |
text/field-input is invisible |
#BLINK |
text/field blinks |
#REVERSE |
background is set with defined colour text appears white |
#USCORE |
Underscore field |
Colors:
Attribute |
Description |
|---|---|
#BLUE |
text or input field is of blue colour |
#RED |
text or input field is of red colour |
#PINK |
text or input field is of pink colour |
#GREEN |
text or input field is of green colour |
#TURQ |
text or input field is of turquoise colour |
#YELLOW |
text or input field is of yellow colour |
#WHITE |
text or input field is of white colour |
You can combine several attribute bytes by adding them. e.g. #PROT+#BLUE combining several colours is not allowed and may lead to unexpected errors.
23.3.6. FSSTITLE
Displays a centred Title in Screen line 1
- CALL FSSTITLE title-text[,attributes]
Besides the title definition the right hand 25 bytes may contain a short message in case of errors, it overwrites the title part in error situations and automatically resets it, if the enter key is used.
The error field is named ZERRSM and maybe set also by your program.
23.3.7. FSSOPTION
- CALL FSSOPTION [row[,option-length[,attribute1,[attribute2]]]
Creates an OPTIONs line, typically used in a menu to select a menu option:
OPTION ===> ________________________________________________
- Parameters
row – defaults to 2
option-length – defines the line length to proved the option input, default is length of the remaining line
attribute1 – Attribute of “OPTION”, default is #PROT+#WHITE
attribute2 – Attribute of the option line,default is #HI+#RED+#USCORE
23.3.8. FSSCOMMAND
- CALL FSSCOMMAND [row[,option-length[,attribute1,[attribute2]]]
Creates an input line for entering menu options or commands, it appears with the “COMMAND ===>” prefix and is typically located in row 2.:
COMMAND ===> ________________________________________________
- Parameters
row – defaults to 2
option-length – defines the line length to provide the command input, default is length of the remaining line
attribute1 – Attribute of “COMMAND”, default is #PROT+#WHITE
attribute2 – Attribute of the command line,default is #HI+#RED+#USCORE
23.3.9. FSSTOPLINE
- CALL FSSTOPLINE prefix,[row[,option-length[,attribute1,[attribute2]]]
Create an Option/Command Line. FSSTOPLINE is a variation of FSSCOMMAND which allows the free definition of the input line prefix. It is typically located in row 2.:
MY-OPTION ===> ________________________________________________
- Prefix
String which should appear in front of the input line. In the example above it is “MY-OPTION”
- Row
defaults to 2
- Option-length
defines the line length to provide the command input; default is the length of the remaining line
- Attribute1
Attribute of “COMMAND”, default is #PROT+#WHITE
- Attribute2
Attribute of the command line, default is #HI+#RED+#USCORE
23.3.10. FSSMESSAGE
CALL FSSMESSAGE [row[,attribute]]
Creates a message line to display messages. The message line occupies a full-screen line.
- param row
defaults to 3
- param attribute
attribute of message line, default is #PROT+#HI+#RED
A call to FSSZERRLM sets the Message
23.3.11. FSSZERRSM
Set Error/Warning/Info Short Message. The message is set in Field ZERRSM. ZERRSM is automatically created by using an FSSTITLE definition; otherwise, it must be defined explicitly. If implicitly used with the FSSTITLE definitions, it starts on the right-hand side after the end of the message; its length is dependant on the length of the title.
- CALL FSSZERRSM 'message'
23.3.12. FSSZERRLM
Set Error/Warning/Info Long Message. The message is set in Field ZERRLM, which has been defined on the screen by a CALL FSSMESSAGE.
- CALL FSSZERRLM 'message'
23.3.13. FSSFSET
Set Field Content
- CALL FSSFSET 'field',content
Make sure the field-name is enclosed in quotes; otherwise, there is a chance of unwanted substitution by its value!
23.3.14. FSSFGET
Get current Field Content .. function:: Value=FSSFGET(‘field’)
Make sure the field-name is enclosed in quotes; otherwise, there is a chance of unwanted substitution by its value!
23.3.15. FSSFGETALL
Get Contents of all Fields
- Number=FSSFGETALL()
All field contents of the screen are fetched and stored in the associated BREXX fields defined by FSSFIELD(…)
23.3.16. FSSCURSOR
Set Cursor to a Field .. function:: CALL FSSCURSOR ‘field’
23.3.17. FSSCOLOUR
Change Colour of a Field
- CALL FSSCOLOUR 'field',colour-attribute alternatively
- CALL FSSCOLOR 'field' ,colour-attribute
23.3.18. FSSKEY
Return Key entered. When the user presses an action-key on a screen the used key value to return control can be accessed by FSSKEY. The optional parameter CHAR returns it in a translated readable form if not set the value returned is the decimal value assigned to the action key.
- key=FSSKEY([CHAR])
By FSS supported keys:
REXX Variable |
Numeric Value |
Translated Value |
|---|---|---|
#ENTER |
125 |
ENTER |
#PFK01 |
241 |
PF01 |
#PFK02 |
242 |
PF02 |
#PFK03 |
243 |
PF03 |
#PFK04 |
244 |
PF03 |
#PFK05 |
245 |
PF05 |
#PFK06 |
246 |
PF06 |
#PFK07 |
247 |
PF07 |
#PFK08 |
248 |
PF08 |
#PFK09 |
249 |
PF09 |
#PFK10 |
122 |
PF10 |
#PFK11 |
123 |
PF11 |
#PFK12 |
124 |
PF12 |
#PFK13 |
193 |
PF13 |
#PFK14 |
194 |
PF14 |
#PFK15 |
195 |
PF15 |
#PFK16 |
196 |
PF16 |
#PFK17 |
197 |
PF17 |
#PFK18 |
198 |
PF18 |
#PFK19 |
199 |
PF19 |
#PFK20 |
200 |
PF20 |
#PFK21 |
201 |
PF21 |
#PFK22 |
74 |
PF22 |
#PFK23 |
75 |
PF23 |
#PFK24 |
76 |
PF24 |
#CLEAR |
109 |
CLEAR |
#RESHOW |
110 |
RESHOW |
23.3.19. FSSDISPLAY
Displays or Re-Displays the active screen.
- CALL FSSDISPLAY
- CALL FSSREFRESH
23.3.20. Get Screen Dimensions
- width=FSSWidth()
- Returns
number of available columns defined by Emulation
- height=FSSHeight()
- Returns
number of available rows defined by Emulation
23.3.21. Close FSS Environment
Once the Screen Handling is finished it is recommended to terminate the FSS environment with one of:
- CALL FSSTERM
- CALL FSSTERMINATE
- CALL FSSCLOSE
23.4. Creating a Dialog Manager
To handle user’s action-keys, you can set up a simple Dialog Manager, as shown in this example:
1/* ---------------------------------------------------------------------
2* Display screen in primitive Dialog Manager and handle User's Input
3* ---------------------------------------------------------------------
4*/
5do forever
6 fsreturn=fssDisplay() /* Display Screen */
7 if fsreturn='PFK03' then leave /* QUIT requested */
8 if fsreturn='PFK04' then leave /* CANCEL requested */
9 if fsreturn='PFK15' then leave /* QUIT requested */
10 if fsreturn='PFK16' then leave /* CANCEL requested */
11 if fsreturn<>'ENTER' then iterate
12 call fSSgetD() /* Read Input Data */
13 /* Add input checking if needed */
14end
15call fssclose /* Terminate Screen Environment */
23.5. Simple Screen Applications
There is a simple way to create formatted screens using preformatted rexx scripts, and this allows an easy screen setup without coding all the screen definitions manually.
23.5.1. Screen with Attributes in one Column
From BREXX.V2R5M0.SAMPLES(#FSS1COL)
1 /* + ------------------- screen with 1 column
2 * !
3 * ! + -------------- Title line of screen
4 * ! ! */
5frc=FMTCOLUM(1,'One Columned Formatted Screen',
6 ,'1. Input ===>',
7 ,'2. Input ===>',
8 ,'3. Input ===>',
9 ,'4. Input ===>',
10 ,'5. Input ===>',
11 ,'6. Input ===>',
12 ,'7. Input ===>',
13 ,'8. Input ===>',
14 ,'9. Input ===>',
15 )
16do i=1 to _screen.input.0
17 say "User's Input "i'. Input Field: '_screen.input.i
18end
19return
The above definition creates and displays this screen:
------------------------ One Columned Formatted Screen ------------------------
1. Input ===> _________________________________________________________________
2. Input ===> _________________________________________________________________
3. Input ===> _________________________________________________________________
4. Input ===> _________________________________________________________________
5. Input ===> _________________________________________________________________
6. Input ===> _________________________________________________________________
7. Input ===> _________________________________________________________________
8. Input ===> _________________________________________________________________
9. Input ===> _________________________________________________________________
After entering input and pressing enter, you receive the provided input:
------------------------ One Columned Formatted Screen ------------------------
1. Input ===> Brexx
2. Input ===> is
3. Input ===> the
4. Input ===> Best
5. Input ===>
6. Input ===>
7. Input ===>
8. Input ===>
9. Input ===>
The provided input is stored in SCREEN.INPUT.xx an can be used or printed as in this REXX script:
User's Input 1. Input Field: Brexx
User's Input 2. Input Field: is
User's Input 3. Input Field: the
User's Input 4. Input Field: Best
User's Input 5. Input Field:
User's Input 6. Input Field:
User's Input 7. Input Field:
User's Input 8. Input Field:
User's Input 9. Input Field:
23.5.2. Screen with Attributes in two Columns
From BREXX.V2R5M0.SAMPLES(#FSS2COL)
1 /* + ------------------- screen with 2 columns
2 * !
3 * ! + -------------- Title line of screen
4 * ! ! */
5frc=FMTCOLUM(2,'Two Columned Formatted Screen',
6 ,'1. Input ===>',
7 ,'2. Input ===>',
8 ,'3. Input ===>',
9 ,'4. Input ===>',
10 ,'5. Input ===>',
11 ,'6. Input ===>',
12 ,'7. Input ===>',
13 ,'8. Input ===>',
14 ,'9. Input ===>',
15 )
16do i=1 to _screen.input.0
17 say "User's Input "i'. Input Field: '_screen.input.i
18end
19return
you get the attributes in two columns:
------------------------ Two Columned Formatted Screen ------------------------
1. Input ===> _________________________ 2. Input ===> _________________________
3. Input ===> _________________________ 4. Input ===> _________________________
5. Input ===> _________________________ 6. Input ===> _________________________
7. Input ===> _________________________ 8. Input ===> _________________________
9. Input ===> _________________________
Entered input is provided in the same way as in the one column screen example.
23.5.3. Screen with Attributes in three Columns
Just change the number of columns to 3: frc=FMTCOLUM(3,’Three Columned Formatted Screen’,
23.5.4. Screen with Attributes in four Columns
Last option is to place the attributes in four columns: frc=FMTCOLUM(4,’Three Columned Formatted Screen’,
23.5.5. Screen special Attributes
You can tailor the appearance of formatted column screens, by setting _screen.xxxx variables:
23.5.5.1. Presetting Screen input fields
Use _SCREEN.INIT.n=’input-value-as-default’, n is the reference to the field in the FMTCOLUMN definition. 1 is first, 2 second, etc.
Example:
1_SCREEN.INIT.1='FRED'
2_SCREEN.INIT.3='Flintstone'
3_SCREEN.INIT.4='FL2311'
4_SCREEN.INIT.5='Quarry'
Calling the formatted screen, you get a pre-set Screen:
------------------------ One Columned Formatted Screen ---------------------
1. First Name ===> Fred__________________________________________
1. Family Name ===> Flintstone____________________________________
2. UserId ===> FL2311________________________________________
3. Department ===> Quarry________________________________________
23.5.5.2. Input field appearance
If not changed, the input fields appear with an underscore in the available length. You can change it by setting _screen.preset. If you set _screen.preset=’+’ (one character) the input field filled by the character you defined. If you use more than one character _screen.preset=’_ ‘ only the given string is displayed.
23.5.5.3. Input field length
The field length is, by default, delimited by the following field definition in the row, or by the end of the line.
If you want to limit it to a certain length by: _SCREEN.LENGTH.n=field-length n is the field number you want to set. It is sufficient to set just the field length you want to limit.
23.5.5.4. Input Field CallBack Function
Normally, if you press enter, the screen control is giving back to your rexx, and the variable content is returned. If you prefer to check the entered input while your formatted screen is still active, for example, to validate user’s input, you can define a callback function:
_screen.ActionKey='internal-subprocedure'
The internal sub-procedure must be coded without a PROCEDURE statement; else you cannot use the screen input variables
1_screen.ActionKey='checkInput'
2frc=FMTCOLUM(2,'Two Columned Formatted Screen',
3...
4return
5/* --------------------------------------------------------------------
6* Call Back Routine from FMTCOLUMN to check provided Input
7* --------------------------------------------------------------------
8*/
9checkInput:
10 if _screen.input.1 = '' then do
11 call FSSzerrsm 'Field 1 ist mandatory'
12 call FSSzerrlm 'Please enter valid content in Field 1'
13 return 1
14end
15if _screen.input.2 = '' then do
16 call FSSzerrsm 'Field 2 is mandatory'
17 call FSSzerrlm 'Please enter valid content in Field 2'
18 return 1
19end
20...
In case of an error, your call back function can use the FSSzerrsm function, which displays a short message in the formatted screen’s title line and/or the FSSzerrlm function to display a long message. The error message is displayed in the last line of Formatted Screen. Your callback sub-procedure signals with its return code how to proceed:
Return |
Description |
|---|---|
return 0 |
everything ok, leave screen an pass control back to calling rexx |
return 128 |
something is wrong, re-display the screen |
return 256 |
something is wrong, leave the screen |
return n: |
field n contains wrong input, re-display screen n >0 and n<128 represents the field number in error |
23.7. FSS Functions as Host Commands
Alternatively to the FSS functions described in ”FSS Function Overview” you can use the FSS Host command API directly. In this case, all definitions, calculations, validations, etc. must be handled by your REXX script directly.
23.7.1. INIT FSS Environment
Initialise the FSS environment; this must be performed before any other FSS call:
ADDRESS FSS
'INIT'
23.7.2. Defining a Text Entry
ADDRESS FSS
'TEXT 'row column attributes text'
text: text to be displayed on the screen
row: row where text should be placed
column: column where text should be placed.
attributes: screen attributes, like colours, protected, high-lighted etc. For details refer to the attributes section
23.7.3. Defining a Field Entry
ADDRESS FSS
'FIELD 'row column attributes field flen [preset]'
text: text to be displayed on the screen
row: row where text should be placed
column: column where text should be placed.
attributes: screen attributes, like colours, protected, high-lighted etc. For details refer to the attributes section
field: Screen field name
flen: length of input area representing field name
preset: content initially displayed (optional), defaults to blank
23.7.4. Getting Field Content
ADDRESS FSS
'GET FIELD field rexx-variable'
field: Screen field name
rexx-variable: variable receiving the field content
23.7.5. Setting Field Content
ADDRESS FSS
'SET FIELD field value'
or
ADDRESS FSS
'SET FIELD field 'rexx-variable'
field: Screen field name
value: new field content
rexx-variable: variable containing the field content
23.7.6. Setting Cursor to a field
Sets the cursor to the beginning of the Screen Field
ADDRESS FSS
'SET CURSOR field'
field: Screen field name
23.7.7. Setting Colour
Sets the Colour of a Screen Field
ADDRESS FSS
'SET COLOR field/text colour'
field: Screen field name
colour: Color definition,for details refer to the attributes section
23.7.8. Getting action Key
When the user presses an action-key on a screen, the key value can be fetched in a rexx-variable:
ADDRESS FSS
'GET AID rexx-variable'
rexx-variable: variable receiving the action key
23.7.9. Display or Refresh Formatted Screen
Used to display the Formatted Screen the first time, or to refresh an active screen:
ADDRESS FSS
'REFRESH'
23.7.10. End or Terminates FSS Environment
Ends the Formatted Screen environment and releases all used main storage:
ADDRESS FSS
'TERM'
23.7.11. Get Terminal Width
ADDRESS FSS
'GET WIDTH rexx-variable'
rexx-variable: variable receiving the action key
23.7.12. Get Terminal Height
ADDRESS FSS
'GET HEIGHT rexx-variable'
rexx-variable: variable receiving the action key