rexx programing

Upload: margret-sebastian

Post on 06-Apr-2018

275 views

Category:

Documents


8 download

TRANSCRIPT

  • 8/3/2019 Rexx Programing

    1/92

    Rexx ProgrammingRexx Programming 1 1

    REXX Programming REXX Programming

  • 8/3/2019 Rexx Programing

    2/92

    Rexx ProgrammingRexx Programming 2 2

    INTRODUCTIONINTRODUCTION

    What is REXX ?

    REstructured eXtended eXecuter

    Simple Programming Language

    Can run Inside / Outside of a

    TSO/E Address Space

  • 8/3/2019 Rexx Programing

    3/92

    Rexx ProgrammingRexx Programming 3 3

    Fe atur e s of REXXFe atur e s of REXX Ease to Use

    Free Format

    Convenient Built - in Functions

    Debugging Capabilities

    Interpreted Language

    Extensive Parsing capabilities

  • 8/3/2019 Rexx Programing

    4/92

    Rexx ProgrammingRexx Programming 4 4

    Compon e nts of REXXCompon e nts of REXX

    Instructions

    Built in Functions TSO/E External Functions Data Stack Functions

  • 8/3/2019 Rexx Programing

    5/92

    Rexx ProgrammingRexx Programming 5 5

    W riting a REXX Exec W riting a REXX Exec

  • 8/3/2019 Rexx Programing

    6/92

    Rexx ProgrammingRexx Programming 6 6

    What is a REXX Ex ec ?What is a REXX Ex ec ?

    Contains REXX language Instructions andCommands

    Starts with the comment line with the wordREXX

    Exampl e :/* REXX */Say This is my First REXX program

  • 8/3/2019 Rexx Programing

    7/92

    Rexx ProgrammingRexx Programming 7 7

    Sy ntax of REXX Instru c tionsSy ntax of REXX Instru c tions

    Lit e ral S tring Using Single quotes

    Using double quotes

    F ormat of a REXX Instru c tion Can begin in any column on any line Comma (,) used as a continuation

    character Semi colon (;) indicates the end of an

    Instruction

  • 8/3/2019 Rexx Programing

    8/92

    Rexx ProgrammingRexx Programming 8 8

    Typ e s of REXX Instru c tionsTyp e s of REXX Instru c tions

    Ke yw ordAssignm e nt

    Lab e lNullCommand

  • 8/3/2019 Rexx Programing

    9/92

    Rexx ProgrammingRexx Programming 9 9

    Op e ratorsOp e rators

    Comparison Op e rators

    Logi c al (Bool e an) Op e rators

    Con c at e nation Op e rators

  • 8/3/2019 Rexx Programing

    10/92

    Rexx ProgrammingRexx Programming 10 10

    Controlling th e F lo w Within an Ex ecControlling th e F lo w Within an Ex ec

    Conditional Instru c tion

    IF / THEN / ELSE Instruction SELECT / WHEN / OTHERWISE / END Instruction

    Looping Instru c tion

    Repetitive LoopsLEAVEITERATE

    Conditional Loops

    Int e rrupt Instru c tion

    EXIT SIGNAL CALL / RETURN

  • 8/3/2019 Rexx Programing

    11/92

    Rexx ProgrammingRexx Programming 11 11

    S ubroutin e s & F un c tionsS ubroutin e s & F un c tions

    Made up of sequence of instruction that can receive data , processthe data and return a value (Optional for Subroutine & Mandatory for Functions)

    Passing the Information

    RESULT

    PROCEDURE Instruction

    PROCEDURE EXPOSE Instruction

  • 8/3/2019 Rexx Programing

    12/92

    Rexx ProgrammingRexx Programming 12 12

    BuiltBuilt--In F un c tionsIn F un c tions

    Arithm e tic F un c tions

    ABS - Returns the Absolute value of the input number

    MAX - Returns the largest number from the list specified

    MIN - Returns the smallest number from the list specified

    RANDOM - Returns a quasi-random, non-negative whole

    number in the range Specified

  • 8/3/2019 Rexx Programing

    13/92

    Rexx ProgrammingRexx Programming 13 13

    BuiltBuilt--In F un c tions ..In F un c tions .. ContdContd

    Comparison F un c tion:

    COMPARE :

    Returns 0 if the two input strings are identical. Otherwisereturns the position of the first character that doesnt match.

    DATATYPE :

    Returns a String indicating the input data type of the inputstring such as Number or Character.

  • 8/3/2019 Rexx Programing

    14/92

    Rexx ProgrammingRexx Programming 14 14

    BuiltBuilt--In F un c tions ..In F un c tions .. ContdContd

    Conv e rsion F un c tions :

    B2X Binary to Hexadecimal

    C2D Character to Decimal

    F ormatting F un c tions:

    CENTER / CENTRE Returns a String of a specifiedlength with the input string centeredin it.

    COPIES Returns the specified number of concatenatedcopies of the input string.

    LEFT / RIGHT Returns a String of the specified lengthtruncated or padded on the Right / Left asneeded.

  • 8/3/2019 Rexx Programing

    15/92

    Rexx ProgrammingRexx Programming 15 15

    BuiltBuilt--In F un c tions ..In F un c tions .. ContdContd

    S tring Manipulating F un c tion:

    INDEX Returns the character position of the first character of the specified string found in the input string.

    LENGTH Returns the Length of the Input String.

    STRIP Returns a character String after removing leading or

    trailing character or both from the Input String.

    SUBSTR Returns a portion of the Input String beginning ata specified character position.

  • 8/3/2019 Rexx Programing

    16/92

    Rexx ProgrammingRexx Programming 16 16

    S tring Manipulating F un c tionsS tring Manipulating F un c tions.... ContdContd

    WORD Returns a word from the Input String as indicatedby a specified number.

    WORDS Returns a number of words in the Input String.

    VERIFY Returns a number indicating whether an inputString is composed only of characters fromanother input string or returns the character position of the first unmatched character.

  • 8/3/2019 Rexx Programing

    17/92

    Rexx ProgrammingRexx Programming 17 17

    BuiltBuilt--In F un c tions ..In F un c tions .. ContdContd

    y Mis ce llan e ous fun c tions:

    DATE Returns the date in the default format(dd mon yyyy) or inone of the various optional format.

    TIME Returns the local time in the default 24 hour clock format(hh:mm:ss) or in one of the various optional formats.

    USERID Returns the TSO/E user id, if the REXX exec is runningTSO/E address space.

  • 8/3/2019 Rexx Programing

    18/92

    Rexx ProgrammingRexx Programming 18 18

    Passing InformationPassing Information

    S AY Passing Information to th e Te rminal

    PULL Ge tting Information from th e Te rminal

    ARG S p ec if ying th e inputs w hil e invoking th e e xec s P e riods (.) w ill a c t as th e dumm y variabl e s

    PAR S E Pr e ve nting th e translation of Upp e r c as e

  • 8/3/2019 Rexx Programing

    19/92

    Rexx ProgrammingRexx Programming 19 19

  • 8/3/2019 Rexx Programing

    20/92

    Rexx ProgrammingRexx Programming 20 20

  • 8/3/2019 Rexx Programing

    21/92

    Rexx ProgrammingRexx Programming 21 21

  • 8/3/2019 Rexx Programing

    22/92

    Rexx ProgrammingRexx Programming 22 22

  • 8/3/2019 Rexx Programing

    23/92

    Rexx ProgrammingRexx Programming 23 23

  • 8/3/2019 Rexx Programing

    24/92

  • 8/3/2019 Rexx Programing

    25/92

    Rexx ProgrammingRexx Programming 25 25

    Compound Variabl e s & S te msCompound Variabl e s & S te ms

    Compound Variables

    a way to create a multi dimensional array or a list of variablesin REXX.

    Stems

    First variable name and the first period of a compound variable Every compound variable begins with a stem

  • 8/3/2019 Rexx Programing

    26/92

    Rexx ProgrammingRexx Programming 26 26

  • 8/3/2019 Rexx Programing

    27/92

    Rexx ProgrammingRexx Programming 27 27

  • 8/3/2019 Rexx Programing

    28/92

    Rexx ProgrammingRexx Programming 28 28

    Parsing DataParsing Data

    PARSE UPPER PULLPARSE UPPER ARGPARSE UPPER VAR

    For Examplequote = Knowledge is powerPARSE UPPER VAR quote word1 word2 word3

    PARSE UPPER VALUE For Example

    PARSE UPPER VALUE Knowledge is power WITH word1word2 word3.

  • 8/3/2019 Rexx Programing

    29/92

    Rexx ProgrammingRexx Programming 29 29

  • 8/3/2019 Rexx Programing

    30/92

    Rexx ProgrammingRexx Programming 30 30

  • 8/3/2019 Rexx Programing

    31/92

    Rexx ProgrammingRexx Programming 31 31

    Commands from an Ex ecCommands from an Ex ec

    TSO/E REXX COMMANDS

    Provided with the TSO/E implementation of the language Will do the REXX related tasks in an execs. For Example

    EXECIO Controls the I/O operations to and from the dataset

    NEWSTACK & DELSTACK Perform data stack services

    SUBCOM Checks for the existence of a host commandEnvironment.

  • 8/3/2019 Rexx Programing

    32/92

    Rexx ProgrammingRexx Programming 32 32

    Commands from an Ex ec .Commands from an Ex ec . ContdContd

    Host Commands :

    Recognized by the Host Environment in which an exec runs.

    RC is set to the return code of the Host Command issued Enclose the Command within single or double quotation marks For Example

    ALLOC DA(NEW.DATA) LIKE(OLD.DATA) NEW

    name = myrexx.execLISTDS name STATUS

  • 8/3/2019 Rexx Programing

    33/92

    Rexx ProgrammingRexx Programming 33 33

    Host Command Environm e ntsHost Command Environm e nts

    TSO Default Host command EnvironmentISPEXEC The environment in which the ISPF commands execute.ISREDIT The environment in which ISPF/PDF EDIT commands execute.

    ADDRESS The command used to change the Host Command Environment. For Example

    ADDRESS ISPEXECEDIT DATASET(datasetname)

  • 8/3/2019 Rexx Programing

    34/92

    Rexx ProgrammingRexx Programming 34 34

  • 8/3/2019 Rexx Programing

    35/92

    Rexx ProgrammingRexx Programming 35 35

  • 8/3/2019 Rexx Programing

    36/92

    Rexx ProgrammingRexx Programming 36 36

  • 8/3/2019 Rexx Programing

    37/92

    Rexx ProgrammingRexx Programming 37 37

  • 8/3/2019 Rexx Programing

    38/92

    Rexx ProgrammingRexx Programming 38 38

    Data S ta c kData S ta c k

    Expandable data structure to store the informationSTACK - Last In First Out (LIFO)QUEUE First In First Out (FIFO)PUSH Puts one item of data on the top of the Data StackQUEUE - puts one item of data on the bottom of the Data StackQUEUED() Total number of elements in a Data Stack

    PARSE EXTERNAL Gets the input directly from the terminal andby pass the data stack.

  • 8/3/2019 Rexx Programing

    39/92

    Rexx ProgrammingRexx Programming 39 39

  • 8/3/2019 Rexx Programing

    40/92

    Rexx ProgrammingRexx Programming 40 40

  • 8/3/2019 Rexx Programing

    41/92

    Rexx ProgrammingRexx Programming 41 41

  • 8/3/2019 Rexx Programing

    42/92

    Rexx ProgrammingRexx Programming 42 42

  • 8/3/2019 Rexx Programing

    43/92

    Rexx ProgrammingRexx Programming 43 43

  • 8/3/2019 Rexx Programing

    44/92

    Rexx ProgrammingRexx Programming 44 44

  • 8/3/2019 Rexx Programing

    45/92

    Rexx ProgrammingRexx Programming 45 45

    TS O/E Ext e rnal F un c tionsTS O/E Ext e rnal F un c tions

    LISTDSI To retrieve the detailed information about a datasets attribute. The attribute information will be stored in a system variables. For Example

    x = LISTDSI(proj5.rexx.exec)

    SYSDSNAME - Dataset nameSYSUNIT - Device unit

    SYSDSORG - Dataset OrganizationSYSRECFM - Record FormatSYSLRECL - Logical Record Length

  • 8/3/2019 Rexx Programing

    46/92

    Rexx ProgrammingRexx Programming 46 46

  • 8/3/2019 Rexx Programing

    47/92

    Rexx ProgrammingRexx Programming 47 47

  • 8/3/2019 Rexx Programing

    48/92

    Rexx ProgrammingRexx Programming 48 48

  • 8/3/2019 Rexx Programing

    49/92

    Rexx ProgrammingRexx Programming 49 49

    TS O/E Ext e rnal F un c tions.TS O/E Ext e rnal F un c tions. ContdContd

    OUTTRAP Puts lines of command output into a series of numbered

    variables each with the same prefix. These variables will save the command output. Specify the variable name in parentheses following the function

    call. For Example

    X = OUTTRAP(var.)

    LISTCX = OUTTRAP(OFF)

  • 8/3/2019 Rexx Programing

    50/92

    Rexx ProgrammingRexx Programming 50 50

  • 8/3/2019 Rexx Programing

    51/92

    Rexx ProgrammingRexx Programming 51 51

  • 8/3/2019 Rexx Programing

    52/92

    Rexx ProgrammingRexx Programming 52 52

  • 8/3/2019 Rexx Programing

    53/92

    Rexx ProgrammingRexx Programming 53 53

    TS O/E Ext e rnal F un c tions.TS O/E Ext e rnal F un c tions. ContdContd

    PROMPT Prompting the user for the valid input for the TSO/E commands TSO/E Profile - For the terminal session

    TSO PROFILE PROMPT

    TSO PROFILE NOPROMPT TSO/E EXEC commandWhen invoking an exec with the EXEC command, can specify thePROMPT operand to set prompting on for the TSO commandsIssued within the exec.The default value is NOPROMPT

    PROMPT External FunctionPROMPT(ON) to set the PROMPT optionPROMPT(OFF) to set the NOPROMPT option

  • 8/3/2019 Rexx Programing

    54/92

    Rexx ProgrammingRexx Programming 54 54

  • 8/3/2019 Rexx Programing

    55/92

    Rexx ProgrammingRexx Programming 55 55

  • 8/3/2019 Rexx Programing

    56/92

    Rexx ProgrammingRexx Programming 56 56

  • 8/3/2019 Rexx Programing

    57/92

    Rexx ProgrammingRexx Programming 57 57

  • 8/3/2019 Rexx Programing

    58/92

    Rexx ProgrammingRexx Programming 58 58

  • 8/3/2019 Rexx Programing

    59/92

    Rexx ProgrammingRexx Programming 59 59

    TS O/E Ext e rnal F un c tions.TS O/E Ext e rnal F un c tions. ContdContd

    SYSDSN Determines if a specified dataset is available or not For Example

    X = SYSDSN(myrexx.exec)The value of X will be OK if it is available for use otherwiseThe value of the X will be

    MEMBER SPECIFIED, BUT DATASET IS NOT PARTITIONED

    MEMBER NOT FOUNDDATASET NOT FOUND

    PROTECTED DATASETUNAVAILABLE DATASETINVALID DATASET NAME, data-set-name:

    MISSING DATASET NAME

  • 8/3/2019 Rexx Programing

    60/92

    Rexx ProgrammingRexx Programming 60 60

  • 8/3/2019 Rexx Programing

    61/92

    Rexx ProgrammingRexx Programming 61 61

  • 8/3/2019 Rexx Programing

    62/92

    Rexx ProgrammingRexx Programming 62 62

  • 8/3/2019 Rexx Programing

    63/92

    Rexx ProgrammingRexx Programming 63 63

  • 8/3/2019 Rexx Programing

    64/92

    Rexx ProgrammingRexx Programming 64 64

    TS O/E Ext e rnal F un c tions.TS O/E Ext e rnal F un c tions. ContdContd

    SYSVAR Retrieves the information about the MVS , TSO/E and the

    current session, such as logon procedure and the user id. Information retrieved depends upon the argument specified. For example

    Argument Value DescriptionSYSPREF Prefix as defined in user profile

    SYSPROC Logon procedure of current sessionSYSUID User id of the current session

  • 8/3/2019 Rexx Programing

    65/92

    Rexx ProgrammingRexx Programming 65 65

    Dynami c Modifi c ation of a S ingl e REXXDynami c Modifi c ation of a S ingl e REXXExpr e ssionExpr e ssion

    INTERPRET Instruction

    Evaluate the expression and also treat it as an instruction after itis evaluated

    For Exampleaction = DO 3 ; SAY HELLO ; END INTERPRET action

  • 8/3/2019 Rexx Programing

    66/92

    Rexx ProgrammingRexx Programming 66 66

    Pro ce ss Information to and from th e Pro ce ss Information to and from th e Data S e tsData S e ts

    Using EXECIO reads information from a data set to the data stack (or a list of variables) and

    writes information from the data stack (or list of variables) back to a data set. The dataset must be either sequential or a single member of a PDS. OPTIONS with DISKR / DISKRU

    OPENFINISSTEMSKIPLIFOFIFO

    OPTIONS with DISKW

    OPENFINISSTEM

    QUEUE Used to queue a null line at the bottom of the stack to indicate theend of the information

  • 8/3/2019 Rexx Programing

    67/92

    Rexx ProgrammingRexx Programming 67 67

    EXECIO ..EXECIO .. ContdContd

    Re turn Cod e s from EXECIO Command

    0 - Normal Completion1 - Data was truncated during the DISKW

    operation.2 - End of file Reached before the number of lines

    were read during DISKR / DISKRU operation.4 - An empty dataset was found during the DISKR

    / DISKRU operation.20 - Severe error .

  • 8/3/2019 Rexx Programing

    68/92

    Rexx ProgrammingRexx Programming 68 68

    Executing a REXX Exec

  • 8/3/2019 Rexx Programing

    69/92

    Rexx ProgrammingRexx Programming 69 69

    Ex ec uting th e REXX Ex ecEx ec uting th e REXX Ex ec

    Explicit Execution

    EXEC command runs the non-compiled REXX programs in

    TSO/E. Enter EXEC command followed by the dataset name thatcontains the exec and keyword exec to distinguish it from theCLIST.

    For Example

    EXEC SHRTEST.SHREXB.EXEC(SEARCH) execEXEC SHREXB(SEARCH) exec

  • 8/3/2019 Rexx Programing

    70/92

    Rexx ProgrammingRexx Programming 70 70

    Ex ec uting th e REXX Ex ec .Ex ec uting th e REXX Ex ec . ContdContd

    Implicit Execution Running the Exec by simply entering the member name of the

    dataset that contains the exec. Allocate the PDS that contains the execs to the system file

    SYSPROC or SYSEXEC SYSPROC

    Is a system file whose dataset can contain both CLISTS and EXEC SYSEXEC

    Is a system file whose dataset can contain only the EXECs. If both the system files are available, SYSEXEC will be

    searched first.

  • 8/3/2019 Rexx Programing

    71/92

    Rexx ProgrammingRexx Programming 71 71

  • 8/3/2019 Rexx Programing

    72/92

    Rexx ProgrammingRexx Programming 72 72

  • 8/3/2019 Rexx Programing

    73/92

    Rexx ProgrammingRexx Programming 73 73

  • 8/3/2019 Rexx Programing

    74/92

    Rexx ProgrammingRexx Programming 74 74

  • 8/3/2019 Rexx Programing

    75/92

    Rexx ProgrammingRexx Programming 75 75

    Ex ec uting th e REXX Ex ec .Ex ec uting th e REXX Ex ec . ContdContd

    Through Batch Mode

    Program IKJEFT01 will be used to submit the REXX execs inBatch mode

    The member name and the arguments will be passed thru thePARM parameter.

    The PDS that contains the member exec will be mentioned inSYSEXEC DD statement.

    The output (if any) from the REXX exec will be stored inthe dataset mentioned in the SYSTSPRT DD statement.

  • 8/3/2019 Rexx Programing

    76/92

    Rexx ProgrammingRexx Programming 76 76

  • 8/3/2019 Rexx Programing

    77/92

    Rexx ProgrammingRexx Programming 77 77

    D ebugging the REXX Exec

  • 8/3/2019 Rexx Programing

    78/92

    Rexx ProgrammingRexx Programming 78 78

    De bugging th e REXX Ex ecDe bugging th e REXX Ex ec

    TRACE

    Displays how the language processor evaluates eachoperations.

    TRACE I (Trace Intermediates)Will Trace the Intermediate states of the Expression or anInstruction.

    TRACE R (Trace Results)Will Trace the Result or Output of the Expression or an Instruction.

  • 8/3/2019 Rexx Programing

    79/92

    Rexx ProgrammingRexx Programming 79 79

  • 8/3/2019 Rexx Programing

    80/92

    Rexx ProgrammingRexx Programming 80 80

  • 8/3/2019 Rexx Programing

    81/92

    Rexx ProgrammingRexx Programming 81 81

  • 8/3/2019 Rexx Programing

    82/92

    Rexx ProgrammingRexx Programming 82 82

    De bugging th e REXX Ex ec .De bugging th e REXX Ex ec . ContdContd

    SPECIAL VARIABLES

    RC Will contain the Return code the latest command

    SIGL The line number from which there was a transfer of control because of the function call, a SIGNALinstruction , or a call instruction.

    Interactive Debug Facility

    EXECUTIL TS(TRACE Start)EXECUTIL TE(TRACE End)

    Option within Interactive Trace

  • 8/3/2019 Rexx Programing

    83/92

    Rexx ProgrammingRexx Programming 83 83

  • 8/3/2019 Rexx Programing

    84/92

    Rexx ProgrammingRexx Programming 84 84

  • 8/3/2019 Rexx Programing

    85/92

    Rexx ProgrammingRexx Programming 85 85

  • 8/3/2019 Rexx Programing

    86/92

  • 8/3/2019 Rexx Programing

    87/92

    Rexx ProgrammingRexx Programming 87 87

  • 8/3/2019 Rexx Programing

    88/92

    Rexx ProgrammingRexx Programming 88 88

  • 8/3/2019 Rexx Programing

    89/92

    Rexx ProgrammingRexx Programming 89 89

  • 8/3/2019 Rexx Programing

    90/92

    Rexx ProgrammingRexx Programming 90 90

  • 8/3/2019 Rexx Programing

    91/92

    Rexx ProgrammingRexx Programming 91 91

  • 8/3/2019 Rexx Programing

    92/92

    Thank You..