Rexx Power Tools - The PARSE Command

Similar documents
Self-test TSO/E REXX. Document: e0167test.fm 19/04/2012. ABIS Training & Consulting P.O. Box 220 B-3000 Leuven Belgium

IBM. TSO/E REXX User's Guide. z/os. Version 2 Release 3 SA

See the mechanics of how to do this for a cycle-driven process with a high degree of usability and easy job output management.

REXX programming for the z/os programmer

REXX Language Coding Techniques

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */

Configuring ISPF for Fun and Profit

TSO/E REXX User s Guide

SHARE 119 August IBM Corporation. The information contained in this presentation is provided for informational purposes only.

Rexx Parse Templates. Chip.

Also, if you need assistance with any of the lab material or exercises, please raise your hand and someone will come to assist you.

IBM Software. REXX Language Coding Techniques. Tracy Dean, IBM June , 2015 IBM Corporation

IBM Systems. Introduction to z/vm Rexx Hands-on Lab. Updated with answers to lab exercises

IBM Software. REXX Language Coding Techniques SHARE Session # Tracy Dean, IBM 2014, 2015 IBM Corporation

z/os PARMLIB Successful Practices - User Experience

Enterprise Modernisation. Customising RDz with Menu Manager. A.Rudd, Datev eg 1

REXX Language Coding Techniques

This paper is based on a session I presented at the Enterprise Modernisation Conference held in Stuttgart in May Updated March 19, 2010

IBM Software. REXX Language Coding Techniques. SHARE Session # Tracy Dean, IBM August IBM Corporation

Uni Hamburg Mainframe Summit z/os The Mainframe Operating. Part 2 TSO, ISPF und Unix Shell. Introduction to the new mainframe

z/os PARMLIB Successful Practices - User Experience

Using REXX during Assembly

Legac-E Education. Passing Parameters. to COBOL sub-routines

REXX For PIE/CICS User Guide. Release 3.3.0

Dynamic ISPF. How to Eliminate All Those Datasets in the LOGON PROC Part 2

Dynamic ISPF. How to Eliminate All Those Datasets in the LOGON PROC Part 1

Practical Usage of TSO REXX

Chapter 2 REXX STATEMENTS. SYS-ED/ Computer Education Techniques, Inc.

SAS Interfaces to ISPF and REXX

CA Mainframe Network Management

Full file at

IBM. User Guide and Reference. REXX for CICS Transaction Server. Version 1 Release 1

Introduction to REXX Workshop

IT 374 C# and Applications/ IT695 C# Data Structures

5) Debugging and error trapping

variable, and executes a clist.

An Introduction to Using REXX with Language Environment

IBM. TSO/E User's Guide. z/os. Version 2 Release 3 SA

z/os Learning Center: Introduction to ISPF Unit 2: Editing with ISPF Module 2: Using ISPF Editing Commands

Chapter 2 TSO COMMANDS. SYS-ED/ Computer Education Techniques, Inc.

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

Chapter 2 Basic Elements of C++

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

IBM. TSO/E System Programming Command Reference. z/os. Version 2 Release 3 SA

STATISTICAL TECHNIQUES. Interpreting Basic Statistical Values

REXX Language Coding Techniques

2. Numbers In, Numbers Out

Browsing MVS Control Blocks Using DDLIST/ISRDDN Under ISPF.

z/os Version 2 Release 3 TSO/E User's Guide IBM SA

2. Numbers In, Numbers Out

Parsing Combinators: Introduction & Tutorial

Interactive MATLAB use. Often, many steps are needed. Automated data processing is common in Earth science! only good if problem is simple

An Introduction to Using REXX with Language Environment

Why Pointers. Pointers. Pointer Declaration. Two Pointer Operators. What Are Pointers? Memory address POINTERVariable Contents ...

z/os Basic Skills Information Center: ISPF Course Module Module 1: Main Features of ISPF

IBM. OMEGAVIEW and OMEGAVIEW II for the Enterprise. Configuring OMEGAVIEW and OMEGAVIEW II for the Enterprise. Tivoli. Version 3.1.

ISPF Users Boot Camp - Part 2 of 2

EnableBasic. The Enable Basic language. Modified by Admin on Sep 13, Parent page: Scripting Languages

Unix Scripts and Job Scheduling. Overview. Running a Shell Script

IBM. CICSPlex SM Messages and Codes. CICS Transaction Server for z/os. Version 5 Release 4

Open Object Rexx. Programming Guide. Version Revision 3 Edition November 11, 2005

Configuring Health Checker for z/os Hands-on Lab

COMP1730/COMP6730 Programming for Scientists. Data: Values, types and expressions.

IBM System z Fast Track

IBM Tivoli Decision Support for z/os Version Messages and Problem Determination IBM SH

IBM. MVS Interactive Problem Control System (IPCS) Customization. z/os. Version 2 Release 3 SA

IBM Tivoli Advanced Reporting for DFSMShsm. User s Guide. Version 1 Release 1 SC

PESIT Bangalore South Campus

MVS/QuickRef - Tailoring QW

8) Subroutines and functions

NaviQuest Testing ACS Hands-On Lab

SHARE MVSE Requirements

IBM Education Assistance for z/os V2R1

CS450: Structure of Higher Level Languages Spring 2018 Assignment 7 Due: Wednesday, April 18, 2018

IBM Student Mainframe Challenge Part Two

Programming Language 2 (PL2)

Draw the resulting binary search tree. Be sure to show intermediate steps for partial credit (in case your final tree is incorrect).

Introduction to Python Code Quality

Chapter 2 Author Notes

CS251 Programming Languages Handout # 29 Prof. Lyn Turbak March 7, 2007 Wellesley College

IBM. DFSMS Using the Interactive Storage Management Facility. z/os. Version 2 Release 3 SC

Tools for z/os UNIX System Services

Business Processes and Rules: Siebel Enterprise Application Integration. Siebel Innovation Pack 2013 Version 8.1/8.

Tivoli Decision Support for OS/390 Messages and Problem Determination. Version SH

How & Why We Subnet Lab Workbook

Tivoli Decision Support for OS/390 Administration Guide. Version SH

Tivoli Tivoli Decision Support for z/os

Section 2: Introduction to Java. Historical note

Chapter 1 INTRODUCTION. SYS-ED/ Computer Education Techniques, Inc.

Objectives. In this chapter, you will:

C++ PROGRAMMING. For Industrial And Electrical Engineering Instructor: Ruba A. Salamh

Chapter 3: Programming with MATLAB

XEDIT, EXECs & PIPES. Bob Bates Wells Fargo Bank

PDSE Version 2: Member Generations Practical User Applications

Long (LONGMATH) variables may be used the same as short variables. The syntax is the same. A few limitations apply (see below).

Primitive Data Types: Intro

REXXIUCV: VM REXX PROGRAMMING SUPPORT FOR IUCV SHARE 75 (NEW ORLEANS, LOUISIANA) SESSION O739

Version 2 Release 3. IBM IMS Configuration Manager for z/os User's Guide IBM SC

CA8B: CICS Transaction Server for OS/390 - BMS Map CWI conversion utility. Version 1.0

Transcription:

Rexx Power Tools - The PARSE Command Session 11751 August 7, 2012 Thomas Conley Pinnacle Consulting Group, Inc. (PCG) 59 Applewood Drive Rochester, NY 14612-3501 P: (585)720-0012 F: (585)723-3713 pinncons@rochester.rr.com http://home.rochester.rr.com/pinncons Pinnacle Consulting Group, Inc. 2012. All rights reserved. Permission granted to SHARE to distribute for SHARE 119.

Abstract Do you need to chop up file records into separate data fields? Do you need to pass arguments to subroutines? Would you like to get better performance from your REXX routines? If you answered yes to any of these questions, then this session is for you! Come to this session to learn about the REXX Parse command. Parse is one of the most powerful and flexible REXX commands for handling strings. It's one-stop shopping for nearly anything you want to do with a string. 2

Agenda PARSE Command Flavors PARSE ARG PARSE EXTERNAL (z/os) PARSE LINEIN (oorexx) PARSE NUMERIC (z/os) PARSE PULL PARSE SOURCE 3

Agenda PARSE VALUE PARSE VAR PARSE VERSION PARSE Templates Debugging PARSE Summary Finally 4

PARSE ARG PARSE ARG used to parse arguments passed to Rexx exec or subroutine ARG is a short form for PARSE UPPER ARG DON T use ARG, use PARSE UPPER ARG if you really want uppercase arguments For the function call tomstr(string,2,10), use the following procedure syntax: tomstr : procedure parse arg str, startpos, tomstrlen 5

PARSE ARG If invoking a main Rexx exec: tomstr string 2 10 use the following syntax in exec tomstr: /* rexx */ parse arg str startpos tomstrlen 6

PARSE ARG The PARSE command parse arg str startpos tomstrlen is equivalent to str = arg(1) startpos = arg(2) tomstrlen = arg(3) PARSE has better performance and is much easier to read 7

PARSE EXTERNAL (z/os) PARSE EXTERNAL is used in z/os to read from the terminal if running interactively, or from DD SYSTSIN if running in batch Returns a null string if SYSTSIN is empty, and a Rexx error message if SYSTSIN is not allocated Recommend using other features to pass input to Rexx exec If SYSTSIN is used to invoke Rexx exec, your results may be unpredictable 8

PARSE LINEIN (oorexx) PARSE LINEIN in oorexx will get the next line of the default input stream Shorter form of PARSE VALUE LINEIN() WITH Only recommended if direct access to input stream is required, otherwise, use PARSE PULL 9

PARSE NUMERIC (z/os) PARSE NUMERIC displays current numeric controls in effect in format DIGITS FUZZ FORM On TSO/E: parse numeric numstr puts 9 0 SCIENTIFIC into numstr (defaults) 9 indicates 9-digit precision, 0 is how many digits are ignored during numeric conversions ( fuzz ) and SCIENTIFIC is the exponential notation method 10

PARSE PULL PARSE PULL is used to pull data from the stack (z/os) or external data queue (oorexx) Can also pull data from a terminal if the Rexx is running interactively in z/os, or default input stream if the external data queue is empty in oorexx PULL is short for PARSE UPPER PULL DON T use PULL, use PARSE UPPER PULL if you really want to uppercase input 11

PARSE PULL Common error is to use PULL for file I/O, which will corrupt lowercase text, packed, and binary data (BTDTGTTS) From TSO/E, use this instead: EXECIO 1 DISKR INFILE parse pull inrec INREC will hold the record read from INFILE 12

PARSE SOURCE PARSE SOURCE shows information about environment and how exec was invoked From ISPF, issue tso exec 'ibmuser.tso.jcl(testsrc)' PARSE SOURCE shows: TSO COMMAND TESTSRC SYS00004 IBMUSER.TSO.JCL? TSO ISPF? 13

PARSE SOURCE From TSO READY prompt, issue: exec 'ibmuser.tso.jcl(testsrc)' PARSE SOURCE shows: TSO COMMAND TESTSRC SYS00007 IBMUSER.TSO.JCL? TSO TSO/E? 14

PARSE SOURCE From TSO READY prompt (or batch IKJEFT01), issue: %testsrc PARSE SOURCE shows: TSO COMMAND TESTSRC SYSPROC?? TSO TSO/E? 15

PARSE SOURCE From IRXJCL, use PARM=( TESTSRC ) PARSE SOURCE shows: TSO COMMAND TESTSRC SYSEXEC? TESTSRC MVS MVS? 16

PARSE SOURCE From Windows/XP Command Window, issue: C:\download>rexx version PARSE SOURCE shows: WindowsNT COMMAND C:\download\version.CMD 17

PARSE VALUE PARSE VALUE will parse the result of an expression without having to use an intermediate variable parse value time() with hours ':' mins ':' secs 18

PARSE VAR PARSE VAR <variable> <template> parses the variable according to the patterns defined in the template timevar = time() parse var timevar hours ':' mins ':' secs 19

PARSE VERSION PARSE VERSION displays information regarding the Rexx language level and modification date of the Rexx processor From TSO/E: REXX370 3.48 01 May 1992 From oorexx: REXX-ooRexx_4.1.0(MT) 6.03 5 Dec 2010 20

PARSE TEMPLATES PARSE templates are used by the PARSE VALUE and PARSE VAR commands to split a source string into multiple components The simplest template is a list of variable names, which will parse the source string into a series of blank delimited words The next examples will use the following string: 1...5...1...5...2...5...3...5.. string = ' This is a blank-delimited string' 21

PARSE TEMPLATES 1...5...1...5...2...5...3...5.. string = ' This is a blank-delimited string' parse var string w1 w2 w3 w4 w5. w1 => 'This' w2 => 'is' w3 => 'a' w4 => 'blank-delimited' w5 => 'string' 22

PARSE TEMPLATES The period '.' in a template is a placeholder which acts as a dummy variable in the middle of a template, or collects the remainder of the source string when used at the end of a template If you do not include a period '.' at the end of your template, the last variable in your template will receive whatever is left of the source string 23

PARSE TEMPLATES 1...5...1...5...2...5...3...5.. string = ' This is a blank-delimited string' parse var string w1 w2 w3 w4 w1 => 'This' w2 => 'is' w3 => 'a' w4 => 'blank-delimited string' 24

PARSE TEMPLATES 1...5...1...5...2...5...3...5.. string = ' This is a blank-delimited string' parse var string w1 w2 w3 w4. w1 => 'This' w2 => 'is' w3 => 'a' w4 => 'blank-delimited' 25

PARSE TEMPLATES 1...5...1...5...2...5...3...5.. string = ' This is a blank-delimited string' parse var string w1. w2. w3. w1 => 'This' w2 => 'a' w3 => 'string' 26

PARSE TEMPLATES 1...5...1...5...2...5...3...5.. string = ' This is a blank-delimited string' parse var string w1.. w2 w3. w1 => 'This' w2 => 'blank-delimited' w3 => 'string' 27

PARSE TEMPLATES The next type of PARSE template is the string pattern template The string pattern is a literal or variable string pattern indicating where the source string should be split Literal: parse var string w1 '-' w2. Variable: dash = '-' parse var string w1 (dash) w2. 28

PARSE TEMPLATES 1...5...1...5...2...5...3...5.. string = ' This is a blank-delimited string' parse var string w1 '-' w2. w1 => ' This is a blank' w2 => 'delimited' 29

PARSE TEMPLATES 1...5...1...5...2...5...3...5.. string = ' This is a blank-delimited string' dash = '-' parse var string w1 (dash) w2. w1 => ' This is a blank' w2 => 'delimited' 30

PARSE TEMPLATES The positional pattern template allows the source string to be parsed by character position An absolute positional pattern template is an absolute number or a number with an equal sign '=' preceding it parse var string 5 w1 =10 w2. Most commonly used template for processing fixed-format file records 31

PARSE TEMPLATES 1...5...1...5...2...5...3...5... string = 'Conley Tom Rexx Guru' parse var string 1 lname 15 fname 30 title 39. lname => 'Conley ' fname => 'Tom ' title => 'Rexx Guru' 32

PARSE TEMPLATES A relative positional pattern template is an absolute number preceded by a plus sign '+' or a minus sign '-' parse var string 5 w1 +5 w2. 33

PARSE TEMPLATES 1...5...1...5...2...5...3...5... string = 'Conley Tom Rexx Guru' parse var string 1 lname +14 fname +15 title +9. lname => 'Conley ' fname => 'Tom ' title => 'Rexx Guru' 34

PARSE TEMPLATES Mixing absolute and relative positional patterns can create some "interesting" situations 1...5...1...5...2...5...3 string = 'REstructured extended executor' parse var string var1 3 junk 'X' var2 +1 junk 'X' var3 +1 junk say var1 var2 var3 var1 => 'RE' var2 => 'X' var3 => 'X' Check out PARSE flow chart on pp. 172-174 of the TSO/E Rexx Reference to get the gory details of mixing absolute, relative, and literal templates 35

Debugging PARSE Best way to debug PARSE is to use "trace i" The following PARSE gives an unexpected result for w3 1...5...1...5...2...5...3...5.. string = ' This is a blank-delimited string' parse var string w1.. w2 w3 w1 => 'This' w2 => 'blank-delimited' w3 => ' string' 36

Debugging PARSE trace i shows *-* parse var string w1.. w2 w3 >>> "This" >.> "is" >.> "a" >>> "blank-delimited" >>> " string" 37

Debugging PARSE After adding a period '.' to the end of the template, trace i shows *-* parse var string w1.. w2 w3. >>> "This" >.> "is" >.> "a" >>> "blank-delimited" >>> "string" >.> "" 38

Summary The various flavors of the PARSE command were discussed Several template examples were shown and explained Debugging PARSE by using "trace i" 39

Finally. I m always interested to hear about your experiences with PARSE, so if you have questions or come up with a neat solution to a problem, please feel free to drop me an Email pinncons@rochester.rr.com The TSO/E Rexx Reference can be found at http://publibz.boulder.ibm.com/epubs/pdf/ikj4a370.pdf Grab oorexx at http://rexxla.org 40