KR-220* REXX Day 9 (parsing)
REXX provides a strong parsing feature (way to extract and format data) wherein we can define a template and extract data based on the template. Some examples will make it clear. The PULL statement itself is actually a PARSE PULL statement.
PART1 gets the first word separated by a space and the rest of the data is dumped into PART2; this is a technique to remove unwanted data.
Let’s cover all types of parsing with a single example.
Let’s analyze the code:
DATE = "MON,DEC 24,2007,12:42" COM = ',' PARSE VAR DATE DAY (COM) 5 MONTH +4 DD (COM) YEAR (COM) HH ':' MM
PARSE VAR is the command. DATE is the variable that has to be parsed. The type of parsing is mentioned in italics.
KR-221* DAY 10 of REXX (file handling)
DSN="TEST.SS.DUMMY" "ALLOCATE F(MEMDD) DSN('"DSN"') SHR" "EXECIO 2 DISKR MEMDD 2 (FINIS STEM TEXT."
EXECIO syntax:
Everything after ( are options for EXECIO. The various options we can give are:
ADDRESS TSO will ensure it executes as a TSO command. All external environment commands will be enclosed within double quotes. By default in MVS environment the environment is TSO. So "ALLOCATE F(MEMDD) DSN('"DSN"') SHR MOD" will work fine.
If you have a bunch of external environment commands to execute then give a single ADDRESS command to switch address space and issue all commands.
ADDRESS "TSO" "ALLOCATE F(MEMDD) DSN('"DSN"') SHR MOD" "ALLOCATE F(MEMDD1) DSN('"DSN1"') SHR MOD" "ALLOCATE F(MEMDD2) DSN('"DSN2"') SHR MOD"
One frequent confusion for programmers is how to tell REXX to substitute variable values in an external command before it passes the command to the other environment. Single quote, double quote or no quotes?
Simple example:
Panels are part of ISPF; so strictly speaking panels will fall under ISPF programming (ISPF is like a front-end for TSO).
So we first create a panel and then use REXX to display the panel on the screen and also to capture the data entered by the user on the screen.
We’ll create a simple panel application (that does nothing!). We’ll just capture the input keyed by the user and display it in REXX. So here we go with panel programming.
Create a member in a PDS with the following:
)ATTR # TYPE(TEXT) INTENS(LOW) SKIP(ON) ! TYPE(TEXT) INTENS(HIGH) SKIP(ON) COLOR(YELLOW) ) BODY % !******************************************************************** !************* THIS PANEL DOES NOTHING **************************** !******************************************************************** % +ENTER SOMETHING HERE ===>_VARIABLE# % %_MSG1 % PF3=EXIT )INIT .CURSOR=VARIABLE )PROC &PFPRSD = .PFKEY )END
With that you are done with your first panel in mainframes! There are different sections to a panel:
1.) Attributes section )ATTR Attributes of fields are determined based on the special character used. For example we have defined # as low intensity field on which the cursor position will be skipped. % + and _ are already defined but if required we can override them. _ is used for input fields.
2.) Main body )BODY The main layout is defined here
3.) Initialization section )INIT Here we’ve asked for the cursor to be positioned on the field variable when the screen is first displayed.
4.) Procedure section )PROC Statements to be executed after the panel is displayed. Here we are trapping the value of the PFKEY pressed in the variable PFPRSD (this variable can be used in our REXX code to check for the PF key pressed).
KR-224* DAY 13 of REXX (playing with your front end panel)
Now with the panel created we need to write a REXX code to display the panel and capture information entered by the user.
Effectively you cannot come out of the panel without pressing PF3 because of the final SIGNAL START statement (ensures that the program is always in a loop).
SIGNAL command
The official REXX User’s Guide is ideal for reference purposes.
When working in multiple languages the operators can get confusing – so here is a list for your reference.
Note: Throughout the language, the not character, ¬, is synonymous with the backslash (\). You can use the two characters interchangeably, according to availability and personal preference.
That pretty much wraps the REXX in 6.5 hours series. We’ve covered most of the basic things you need to get working in REXX. So go ahead and start making some utilities for your project – it can help you avoid doing a lot of redundant manual work.
Copyright © 2020 Sethu Subramanian All rights reserved. Reach me via email at ssbell @ gmail.com