REXX Saravanan Desingh. REXX An abbreviation of IBMs Restructured EXtended eXecutor (REXX) Language, which allows system command to be used or combined.

Slides:



Advertisements
Similar presentations
Control Structures Ranga Rodrigo. Control Structures in Brief C++ or JavaEiffel if-elseif-elseif-else-end caseinspect for, while, do-whilefrom-until-loop-end.
Advertisements

Programming Languages and Paradigms The C Programming Language.
PL/SQL.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
ITEC113 Algorithms and Programming Techniques
VBA Modules, Functions, Variables, and Constants
Introduction to Rexx Prof. Chris GauthierDickey COMP 2400: Unix Tools.
Program Design and Development
REXX - part 2 Prof. Chris GauthierDickey COMP Unix Tools.
CS241 PASCAL I - Control Structures1 PASCAL I - Control Structures Philip Fees CS241.
Guide To UNIX Using Linux Third Edition
VB .NET Programming Fundamentals
Basic Elements of C++ Chapter 2.
INTRO TO PROGRAMMING Chapter 2. M-files While commands can be entered directly to the command window, MATLAB also allows you to put commands in text files.
High-Level Programming Languages: C++
Agenda Control Flow Statements Purpose test statement if / elif / else Statements for loops while vs. until statements case statement break vs. continue.
Fortran 1- Basics Chapters 1-2 in your Fortran book.
1 Chapter 9 Writing, Testing, and Debugging Access Applications.
Programmer's view on Computer Architecture by Istvan Haller.
CNG 140 C Programming (Lecture set 9) Spring Chapter 9 Character Strings.
CIS 218 Advanced UNIX1 CIS 218 – Advanced UNIX (g)awk.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
Chapter 4: Control Structures I (Selection). Objectives In this chapter, you will: – Learn about control structures – Examine relational operators – Discover.
Chapter 4: Control Structures I (Selection). Objectives In this chapter, you will: – Learn about control structures – Examine relational and logical operators.
Shell Script Programming. 2 Using UNIX Shell Scripts Unlike high-level language programs, shell scripts do not have to be converted into machine language.
Linux+ Guide to Linux Certification, Third Edition
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
1 C++ Syntax and Semantics, and the Program Development Process.
CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
CIS 260: App Dev I. 2 Programs and Programming n Program  A sequence of steps designed to accomplish a task n Program design  A detailed _____ for implementing.
VBScript Language. What is VBScript Based on the Visual Basic family of languages Supports object oriented features Interpreted Loosely Typed Implicitly.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
Chapter 7 Additional Control Structures. Chapter 7 Topics l Switch Statement for Multi-Way Branching l Do-While Statement for Looping l For Statement.
Visual Basic Programming
Saeed Ghanbartehrani Summer 2015 Lecture Notes #5: Programming Structures IE 212: Computational Methods for Industrial Engineering.
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
Guide to Oracle 10g ITBIS373 Database Development Lecture 4a - Chapter 4: Using SQL Queries to Insert, Update, Delete, and View Data.
Basic Data Types Numbers (integer and floating point)‏ Strings (sequences of characters)‏ Boolean values (true/false)‏
CONTENTS Processing structures and commands Control structures – Sequence Sequence – Selection Selection – Iteration Iteration Naming conventions – File.
Introduction to Matlab Module #4 Page 1 Introduction to Matlab Module #4 – Programming Topics 1.Programming Basics (fprintf, standard input) 2.Relational.
More about Strings. String Formatting  So far we have used comma separators to print messages  This is fine until our messages become quite complex:
©Colin Jamison 2004 Shell scripting in Linux Colin Jamison.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.
Chapter Six Introduction to Shell Script Programming.
CS241 PASCAL I - Control Structures1 PASCAL Control Structures Modified Slides of Philip Fees.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Chapter 4: Control Structures I (Selection). Objectives In this chapter, you will: – Learn about control structures – Examine relational and logical operators.
Introduction to Perl. What is Perl Perl is an interpreted language. This means you run it through an interpreter, not a compiler. Similar to shell script.
Rexx Programming1 REXX Programming. Rexx Programming2 INTRODUCTION What is REXX ?  REstructured eXtended eXecuter  Simple Programming Language  Can.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
Chapter 16 Advanced Bourne Shell Programming. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Objectives To discuss numeric data processing.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Rexx for Shell Scripting or “We don't need no stinkin' bashes...”
Definition of the Programming Language CPRL
Basic Elements of C++.
The Selection Structure
Scripts & Functions Scripts and functions are contained in .m-files
Basic Elements of C++ Chapter 2.
Chapter 7 Additional Control Structures
T. Jumana Abu Shmais – AOU - Riyadh
Programming Languages and Paradigms
Presentation transcript:

REXX Saravanan Desingh

REXX An abbreviation of IBMs Restructured EXtended eXecutor (REXX) Language, which allows system command to be used or combined in a routine.

Topics 1 REXX ENVIRONMENT 2 CODING PROGRAM & DATA INSTRUCTIONS 3 DEBUGGING & STORAGE FACILITIES 4 REXX AS A COMMAND LANGUAGE

1.1 Creating a REXX program. 1.2 Coding Simple variables and Expressions 1.3 Using Built-in functions 1.REXX ENVIRONMENT

1.1.1 Beginning a REXX Program and using comments Structuring a REXX Program Using Basic Terminal I/O Running a REXX Program 1.1 Creating a REXX program

1.1.1 Beginning a REXX program and using comments Start with Keyword REXX Comments /* and */

1.1.2 Structuring a REXX program Free-Formatted Language A Space to separate the arguments Not Case-Sensitive

1.1.2 Structuring a REXX program ;Separate 2 Instructions,Continue an Instruction

1.1.3 Basic terminal input and output instruction SAY –Display Text on Screen PULL –Retrieves User Input

1.1.4 How to Run a REXX program? Explicit Command –TSO Environment exec ‘DSN’ exec Implicit Command –SYSPROC or SYSEXEC TSO member-name

1.2.1 Using Dynamic Typing Assigning simple variable Using Character String Expressions and Operations Using Arithmetic Expressions and Operations Using Logical Expression and Operations 1.2 Coding Simple variables and Expressions

1.2.1 Using Dynamic Typing Implicit Defining of Variables Defined Dynamically

1.2.2 Assigning simple variables Variable Characteristics: –Length 1 to 255 characters –A-Z, a-z, 0-9 –Should not begin with Digits

1.2.3 Using Character String Expressions and Operations All Constants & Variables referred as Alphanumeric Character Strings. Character Strings - “” and ‘’ Concatenation - ||

1.2.4 Using Arithmetic Expressions and Operations Denoted with or without Quotes 12,’12.0’,”12.00” Arithmetic Operators +,-,*,/

1.2.5 Using Logical Expressions and Operations = > < == (Identical to) & | \ (Not)

1.3.1 Using string manipulation function Formatting numbers Using Arithmetic Functions Using Miscellaneous functions 1.3 Using Built-in functions

1.3.1 Using String Manipulation Functions LENGTH(string) – No.of characters in the string LEFT(string,no.of chars) – Isolate a string within a string SUBSTR(string,startpos,no.of chars) RIGHT(string,no.of chars)

1.3.1 Using String Manipulation Functions POS(lookfor,seach) INDEX(search,lookfor) –searches one string (search) to see if another string (lookfor) is contained in it

1.3.2 Formatting Numbers FORMAT(nn,ninteger,ndecimal) nn - Number or numeric expression to format ninterger-Number of digits or blanks to the left of the decimal point. ndecimal-Number of places to the right of the decimal point Ex: A= FORMAT(A,3,1)=123.4

1.3.2 Formatting Numbers TRUNC(number,numberofplaces) Ex: TRUNC( ,1)=56.7

1.3.3 Using Arithmetic Functions DATATYPE(variable) –NUM –CHAR

1.3.3 Using Arithmetic Functions Additional Function: –ABS(n) –MAX(n1, n2, n3...) –MIN(n1, n2, n3….) –RANDOM(low, high) –SIGN(n)-1, 0, 1

1.3.4 Using Miscellaneous Function –USERID() –TIME()Format hh:mm:ss –DATE()Format dd mmm yyyy –DATE(J)Format yyddd –DATE(U)Format mm/dd/yy

2.1 Using Compound variables 2.2 Coding Conditional and Looping Constructs 2.3 Implementing Subroutines, Procedures, and Functions 2.4 Parsing Data 2 CODING PROGRAM & DATA INSTRUCTIONS

Implementing Arrays and Records 2.1 Using Compound variables –Stem –No. of Elements –Maximum Variable Name Length Characters –Mixed types and Lengths –Ex: arr.1=“25” arr.2=“Steeple-Reach Building”

Initialize array: –array.=0 –arr.=‘’

Single and Multi dimension array. –Ex: single.var matrix.row.col

Compound Variables can be used as Data Structures. Ex: emprec.empname=‘Bharath’ emprec.empno=5508 emprec.sex=‘M’ Record like structure.

2.2.1 Using Conditional Constructs and Compound Statements Using Looping Constructs Bypassing and Terminating Loops Branching on errors 2.2 Coding Conditional and Looping Constructs

2.2.1 Using Conditional constructs and Compound statements Conditional group: IF-THEN-ELSE Format: IF expression THEN statement ELSE statement ELSE optional

2.2.1 Using Conditional constructs and Compound statements Grouping the statements: DO-END Ex: DO Statement1 Statement2 END

2.2.1 Using Conditional constructs and Compound statements Selecting several conditions: SELECT-WHEN-THEN-OTHERWISE * OTHERWISE optional

2.2.2 Using Looping Constructs Repeating a sequence of instructions. Conditional Looping. DO-WHILE DO-UNTIL

2.2.2 Using Looping Constructs Format: DO WHILE condition Stmts END Executes when condition is True.

2.2.2 Using Looping Constructs Format: DO UNTIL condition stmts END Executes when condition is False.

2.2.2 Using Looping Constructs Numerically Controlled Repetitive Loop: –Format: DO nooftimes stmts END –Ex: DO 5 say ‘It will be displayed for 5 times’ END

2.2.2 Using Looping Constructs Numerically Controlled Repetitive Loop:(Infinite Looping) –Format: DO FOREVER stmts END –Ex: DO FOREVER say ‘Your System is locked by the User’ END

2.2.2 Using Looping Constructs Numerically Controlled Repetitive Loop: –Format: DO var = initial T0 final stmts END –Ex: DO I=1 to 10 s=s+I END

2.2.2 Using Looping Constructs BY Clause: –Additional variations. Ex: DO I=1 T0 99 BY 2 SUM=SUM+I END ‘I’ will have the values 1,3,5,…99

2.2.2 Using Looping Constructs FOR Clause: –Controls Maximum no. of Execution. Ex: DO I=0 BY 5 FOR 20 SAY I END ‘I’ will have the values 0,5,10,..95

2.2.2 Using Looping Constructs Nested Looping: DO … ……. END

2.2.3 Bypassing and Terminating Loops LEAVE: –Terminating explicitly. Ex: DO FOREVER SAY ‘Enter a String (Exit : X)’ PULL STR IF STR == ‘X’ THEN LEAVE ELSE SAY STR END

2.2.3 Bypassing and Terminating Loops ITERATE: –Bypass instructions. Ex: DO count = 1 TO 10 IF count = 8 THEN ITERATE ELSE SAY 'Number' count END

2.2.4 Branching on Errors SIGNAL: Ex: IF RC\=0 THEN SIGNAL handle-error ……. handle-error: ….

2.3.1 Defining Subroutines, Procedures and Functions Using Subroutines Using Procedures Using Functions 2.3 Implementing Subroutines, Procedures, and Functions

2.3.1 Defining Subroutines, Procedures, and Functions In REXX, use a Subroutine for a simple branch and return within a program. All main program variables are available to a subroutine.

2.3.1 Defining Subroutines, Procedures, and Functions In REXX, use a Procedures the same way as you use a subroutine, but use it when you need a routine with its own local variables ‘hidden’ from the main program.

2.3.1 Defining Subroutines, Procedures, and Functions In REXX, use a Functions to return data to use in the main program. REXX allows functions to either access main program variables or local variables.

2.3.2 Using Subroutines Main pgm, ….. CALL subrtn …… EXIT subrtn: …….. RETURN

2.3.3 Using Procedures Main pgm, ….. CALL subrtn …... EXIT subrtn: PROCEDURE …….. RETURN

2.3.3 Using Procedures Ex: i=4 call num say i num: PROCEDURE i=3 RETURN Output is 4.

2.3.3 Using Procedures EXPOSE: –To expose caller Variables. Format: –ProcName: PROCEDURE EXPOSE arg1 arg2… Argument variables can be constants, expressions or variables

2.3.3 Using Procedures Ex: n1=5 n2=4 avg=0 call calc say avg calc: PROCEDURE EXPOSE n1 n2 avg avg=(n1+n2)/2 RETURN

2.3.3 Using Procedures To pass value, code –A CALL with up to 20 Arguments. The ARG, PARSE UPPER ARG and PARSE ARG instruction as the first line in the PROCEDURE.

2.3.3 Using Procedures Ex: CALL exproc name1 ecode1 exproc: PROCEDURE ARG name2 ecode2 say name2 say ecode2 RETURN

2.3.3 Using Procedures RESULT: –Last value returned from the Procedure or Subroutine Ex: RETURN is assigned to RESULT.

2.3.4 Using Functions User-defined Functions: –Like Built-in function. –Substitutes Expressions. –Subroutines or Procedures returns a value can be used as function Format: –FunctionName()

2.3.4 Using Functions Ex: n1=1 n2=2 say average(n1 n2) average:PROCEDURE ARG n1 n2 RETURN (n1+n2)/2

2.4.1 Parsing from Terminal Input and Passed Values Using Additional Parsing Instructions 2.4 Parsing Data

2.4.1 Parsing from terminal input Format: PULL var or PARSE UPPER PULL var

2.4.1 Parsing from terminal input PULL var1 var2… PARSE UPPER PULL var1 var2.. PARSE PULL var1 var2..

2.4.1 Parsing from passed values Receiving data from the another routine Format: ARG var1 var2.. or PARSE UPPER ARG var1 var2.. Without converting to uppercase, PARSE ARG var1 var2 …

2.4.2 Using additional Parsing Instructions PARSE VAR varname var1 var2 … PARSE VALUE expression WITH var1 var2..

2.4.2 Using additional Parsing Instructions Ex: PARSE VALUE “hello” || “world”, WITH var1 var2 Var1=”hello” Var2=”world”

To Trap and disregard dummy words PARSE VALUE “This is a REXX program” WITH var1.. var2. Var1=”This” Var2=”REXX” PARSE VALUE “Hi, Everybody” WITH var1 ‘,’ var2 Var1=”Hi ” Var2=” Everybody”

3.1 Processing Data on a Stack 3.2 Manipulating Data sets 3.3 Debugging with REXX Facilities 3 DEBUGGING & STORAGE FACILITIES

3.1.1 Defining the stack Implementing LIFO and FIFO lists with the stack 3.1 Processing Data on a Stack

3.1.1 Defining the stack Storage Facility in Memory for lists of Data. Access is Sequential.

3.1.2 Implementing LIFO and FIFO lists with the stack LIFO- Last In First Out FIFO- First In First Out Default is LIFO

3.1.2 Implementing LIFO and FIFO lists with the stack PUSH: To implement a LIFO list on the stack, PUSH expression

3.1.2 Implementing LIFO and FIFO lists with the stack PULL: –As long as the stack contains data lines, PULL accesses the stack. When the stack is empty, PULL accesses the keyboard. PULL var QUEUE: To implement a FIFO list on the stack, QUEUE expression

3.1.2 Implementing LIFO and FIFO lists with the stack QUEUED(): Built-in function used to determine the no. of items in the stack. n=QUEUED()

3.2.1 Reading information from Data sets Writing information to Datasets Updating Data sets 3.2 Manipulating Data sets

ALLOC – allocation EXECIO – input/output operations

3.2.1 Reading information from data sets  Allocate dataset to a file. –“ALLOC F(file) DA(‘DSN’) SHR REUSE” file -> Logical File DSN-> Physical File

3.2.1 Reading information from data sets  Read data into a stack or an array using EXECIO with the DISKR option. –“EXECIO * DISKR file(FINIS” using stack –“EXECIO * DISKR file(STEM arr. FINIS” using array * - all lines.  FINIS- close dataset after processing

3.2.1 Reading information from data sets “EXECIO nooflines DISKR file startlineno (FINIS” nooflines – no. of lines to read. Startlineno - starting line to read. Ex: “EXECIO 10 DISKR file 100(FINIS”

3.2.1 Reading information from data sets stack: “EXECIO * DISKR file(LIFO FINIS” -PUSH command “EXECIO * DISKR file(FIFO FINIS” -QUEUE command - Default is FIFO.

3.2.2 Writing information to data sets DISKW in EXECIO Stack: EXECIO will continue to pull from the stack until it locates a null line.

3.2.3 Updating a data sets DISKRU: –Disk read for updating. Ex: –“EXECIO 1 DISKRU file(LIFO ”

3.3.1 Tracing Program Flow Using Special Variables 3.3 Debugging with REXX Facilities

3.3.1 Tracing Program Flow TRACE: Initiate trace from REXX TRACE C – Commands TRACE R - Results TRACE E - Errors TRACE N - Normal

3.3.1 Tracing Program Flow Interactive Tracing: TRACE ?option option- C,R or E.

3.3.2 Using Special Variables SIGL (Signal Line): Whenever control transfers within a REXX program (usually due to CALL, SIGNAL, or a Function call), SIGL is set to the line number where the branch occurred.

3.3.2 Using Special Variables Ex: CALL subrtn EXIT subrtn: say “This is call from line” SIGL RETURN O/p: This is call from line 3

3.3.2 Using Special Variables RC (Return Code): Retains the return code of the REXX command executed last. Ex: “EXECIO * DISKR f1(FINIS” readcode=RC

3.3.2 Using Special Variables SIGNAL ON ERROR: –Any subsequent nonzero RC cause control to pass to a subroutine named ERROR.

3.3.2 Using Special Variables SIGNAL ON ERROR: Ex: SIGNAL ON ERROR ….. ERROR: Say ‘Error no.’ RC ‘occurred at line’ SIGL EXIT

4.1 Interacting with the Command Host Environment 4.2 Interacting with TSO/E 4 REXX AS A COMMAND LANGUAGE

Directing Commands to the Command Host Environment 4.1 Interacting with the Command Host Environment

To change the command Host Environment for all subsequent commands, use the format, “ADDRESS environment” Environments: MVS, TSO, ISPEXEC, ISREDIT, LINK, ATTACH, or NETVIEW. Ex: “address MVS”

Verify Environment: Format: “SUBCOM environment” Sets RC to zero if the environment is present, else set to one.

4.2.1 TSO Commands Using OUTTRAP to Pass Data 4.2 Interacting with TSO/E

Commonly used TSO Commands –ALLOCATE –DELETE –DSAT –EXEC –LISTDS TSO Commands

4.2.2 Using OUTTRAP to pass Data Traps the output of the subsequent commands and places the trapped lines into an array Format: OUTTRAP(“stem.”,Maxnoof lines) “command” Ex: OUTTRAP(“output.”,5)

THE END