Z vm module 6 the rexx programming language
1 / 45

- PowerPoint PPT Presentation

  • Uploaded on

z/VM Module 6: The REXX Programming Language. Module Objectives. Data structures IF-THEN-ELSE SELECT LOOPS Data formats An example of formatting numbers and strings are: FORMAT( )  numerical SUBSTR( )  string manipulation Input/Output (I/O) functions STREAM( ) function

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about '' - daktari

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Z vm module 6 the rexx programming language l.jpg

z/VMModule 6: The REXX Programming Language

Module objectives l.jpg
Module Objectives

  • Data structures


    • SELECT

    • LOOPS

  • Data formats

    • An example of formatting numbers and strings are:

      • FORMAT( )  numerical

      • SUBSTR( )  string manipulation

  • Input/Output (I/O) functions

    • STREAM( ) function


  • Parameters

    • To retrieve parameters use:

      • ARG, PULL, etc.

Objectives l.jpg

  • Describe REXX and how it works with z/VM

  • Describe how to write REXX programs using:

    • Comments

    • Keywords and literal strings

    • Clauses

    • Syntax error messages

  • Explain the use of REXX variables with names, values, and assignments

Objectives continued l.jpg
Objectives continued

  • Understand which expressions can be used within a REXX clause:

    • Operators and terms

    • Comparisons (equal, and, or)

    • Functions

  • Learn the control statements for manipulating data flow:

    • IF – THEN

    • ELSE keyword

    • DO LOOPS (repetitive and conditional)

    • Selection

Objectives continued5 l.jpg
Objectives continued

  • Explain arithmetic, text, and conversational expressions for manipulating and gathering data

  • Show how to issue CMS and CP commands within a REXX EXEC

  • Explain the subcommands and macros used in REXX EXECs

  • Introduce REXX subroutines

What is rexx l.jpg
What is REXX?

  • REstructured eXtended eXecutor language

  • A versatile, easy to use, structured programming language

  • A programming language that is easy for both computer professionals and general users to learn and use

  • A compiler can be used to translate REXX source programs into compiled programs

Features of rexx l.jpg
Features of REXX

  • Ease of use

  • Free format

  • Interpreted

  • Built-in functions

  • Parsing capabilities

  • Powerful debugger

  • Relationship with z/VM

How a program works l.jpg
How a Program Works

  • A REXX program is a list of instructions, something like a recipe

  • A computer communicates with users through questions displayed and answers typed in

Comments in rexx programs l.jpg
Comments in REXX Programs

  • Comments in programs:

    • /* . . . */, this is used for descriptions and explanations

  • Comments with special meaning to CMS

    • To determine you are writing a REXX program the first line must contain /* . . . */

  • Keywords and literal strings l.jpg
    Keywords and Literal Strings

    • Keywords are instructions that describe an action, such as PULL, IF, and SAY.

    • REXX reads each individual clause, then processes it before going on to the next (interpreted language).

    • A literal string is a set of characters bounded by quotation marks.

    • REXX processes a clause containing a variable by substituting the variable name with the stored data.

    Rexx clauses l.jpg
    REXX Clauses

    • REXX programs consist of these types of clauses:

      • Instruction

      • Assignment

      • Label

      • Null

      • Commands

    Names values and assignments l.jpg
    Names, Values, and Assignments

    • Information stored in a variable is called its value.

    • It is possible to make variable names anything, but a good idea to create meaningful names.

    • An instruction that stores a value in a variable or changes its value is called an assignment.

      • In formal terms, the syntax might look like this:

        • symbol = expression

    Other assignments l.jpg
    Other Assignments

    • The PULL instruction:

      • Pauses the running program to allow the user to enter data

      • Can be used to pull in each piece of data or allow the user to enter multiple amounts of data separated by spaces

    • The ARG instruction:

      • Like PULL, but data items are entered at the command prompt with the program name

    Assignments and instructions l.jpg
    Assignments and Instructions

    • One way to write this EXEC is:

      /* SUBMUL1 EXEC */

      ARG first second

      say first “-” second “=” first-second

      say first “*” second “=” first*second

    • Another way to write this EXEC is:

      /* SUBMUL2 EXEC */

      say “Enter two numbers to multiply and subtract.”

      pull first second

      say first “-” second “=” first-second

      say first “*” second “=” first*second

    Rexx expressions l.jpg
    REXX Expressions

    • Operators and terms:

      • Operators include +, -, /, %, *, ||

      • Operators manipulate numbers, strings in quotes, variables, results from function calls and evaluated expressions

    • Parentheses:

      • The language processor evaluates the expression inside the parentheses first

        • The value of 10 * ( 3 || 4 ) is: 340

    Rexx expressions comparison true and false l.jpg
    REXX Expressions (Comparison, True, and False)

    • Comparisons:

      • > Greater than

      • = Equal

      • < Less than

  • TRUE, the computed result is 1

    • say 4 < 7

      • /* represents a “1”, which means TRUE */

  • FALSE, the computed result is 0

    • say “Chalk” = “Cheese”

      • /* represents a “0”, which meaning FALSE */

  • Rexx expressions19 l.jpg
    REXX Expressions ( =, &, | )

    • The equal sign (=) can have two meanings

      • Can be an assignment if found at the beginning after the symbol

      • An equal sign anywhere else stands for the comparison operator

  • Use the AND (&) operator to write an expression that is true when everything else is also true

  • Use the OR (|) operator when any part of an expression can be true

  • Rexx functions l.jpg
    REXX Functions

    • Function calls can be written anywhere in an expression.

    • The function performs the computation named by the function and returns the result.

    • When the value of the function has been calculated, the result is put back into the expression in place of the function call.

      • An example is:

        • say 7 + HALF(6) /* becomes 7 + 3 which says “10” */

    Examples and notes if then l.jpg
    Examples and Notes: IF - THEN

    • The THEN instruction may be an assignment, command, or keyword.

    • The NOP instruction can be used when no operations are necessary.

    • An important property of the THEN keyword is that is does not need to start a clause, therefore a semicolon is not needed.

    • Another example is:

      • If answer=‘YES’ then say ‘OK!’; else say ‘Why not?’

    Conditional do loops l.jpg
    Conditional DO Loops

    • Conditional loops continue to be executed as long as some condition is satisfied.

    • The simplest way to code these loops is to use DO FOREVER and LEAVE instructions.

    Conditional loops the choice l.jpg
    Conditional Loops: The Choice

    • There are three kinds of Conditional Loops

      • The decision is made before processing starts

        • Checking occurs before entering the loop and continues after each iteration.

      • The decision is made after the first pass through the loop and again after every subsequent pass.

        • Data is requested for the user.

      • The decision is made during each pass.

        • The decision to leave might depend on information obtained during the loop.

    A select instruction l.jpg
    A SELECT Instruction


    WHEN morning THEN DO

    say “Take shower”

    say “Eat breakfast.”

    say “Get ready for work.”


    WHEN afternoon THEN DO until ans=Y

    say “Did you eat lunch? (Y/N)



    otherwise say “It is in the evening -- get ready for bed!!”


    Arithmetic l.jpg

    • The addition, subtraction and multiplication operations are performed in the usual way.

      • +  Addition

      • -  Subtraction

      • *  Multiplication

      • **  Power function

  • The result of a % operation is the whole number portion. The remainder is dropped.

  • The result of a // operation is the remainder portion. The whole number is dropped.

  • The result of a / operator is a combination of both operations above.

  • Text string manipulation l.jpg
    Text – String Manipulation

    • SUBSTR() Function:

      • To select a part of a string to use:

        • WORD = “reveal”

        • say substr(WORD, 2, 3) /* says “eve” */

    • LENGTH() Function:

      • To find out the length of a REXX variable:

        • WORD = "reveal"

        • say length(WORD) /* says "6" */

    Text string manipulation continued l.jpg
    Text – String Manipulation continued

    • COPIES():

      • Produces a number of copies of the string. The arguments are:

        • The string to be copied

        • The number of copies required

  • LEFT():

    • Obtains a string that is padded or truncated on the right

  • RIGHT():

    • Obtains a string that is padded or truncated on the left

  • Conversations say and pull l.jpg
    Conversations – SAY and PULL

    • The SAY instruction and its expression are computed and the result is displayed as a new line on the screen.

    • The PULL instruction is able to collect an answer that has been displayed by the SAY instruction.

    • The PARSE PULL instruction brings in the data just as it is, without converting the lowercase letters to uppercase.

    • The UPPER instruction translates the value of one or more variables to uppercase.

    Conversation parsing words l.jpg
    Conversation – Parsing Words

    • PULL can also fetch each word into a different variable

    • Using the period as a place holder in this statement (PULL . . lastname .) means to discard the first two words and assign the third word to lastname.

    Issuing commands to cms and cp l.jpg
    Issuing Commands to CMS and CP

    • The language processor can operate in a number of environments.

    • Use quotes to avoid errors when writing CMS and CP commands within REXX.

    Issuing commands return codes l.jpg
    Issuing Commands – Return Codes

    • More examples:

      1) access 591 591

      DMSACC113S B(591) not attached or invalid device address

      Ready (00100);

      2) copyfile profile exec a = = b (for luck

      Invalid parameter LUCK in the option FOR field

      Ready (00024);

      3) erase junk exec

      File JUNK EXEC A not found

      Ready (00028)

    Why use a compiler l.jpg
    Why Use a Compiler?

    • Advantages of compiling REXX EXECS

      • Source can be hidden from end users

      • Load modules are loaded into memory faster

    • Compile programs using this CMS command:

      • REXXD [source-file-identifier]

    Xedit subcommands and macros l.jpg
    XEDIT Subcommands and Macros

    • The first word on the command line is assumed to be a subcommand

    • Words that are not subcommands are interpreted as macros

    Conclusion l.jpg

    • REXX was created as a procedural language that allows programs and algorithms to be written in a clear and structured way.

    • Topics in this module:

      • Comments

      • Clauses

      • Variables

      • Expressions

      • Control statements:

        • IF THEN

        • ELSE

        • Loops

        • Selection

    Glossary l.jpg

    Clause – a line of code or a statement within a REXX program

    Parsing – manipulates character strings to let your program read and separate characters, number, and mixed inputs

    PL/I – was developed as the universal programming language, where definitions were not needed

    Glossary44 l.jpg

    • REXX – REstrutured eXtneded eXecutor language, a versatile, easy to use structured programming language that is an integral part of z/VM.

    • REXXCompiler – translates REXX source programs into compiled programs. (Compiled programs run much faster than interpreted programs.)

    References l.jpg

    z/VM: REXX/VM User’s Guide –Version 3 Release 1.0  SC24-5962-00

    The REXX Language: A Practical Approach to Programming –by Michael Cowlishaw

    Website: Rexx Language Association