1 / 134

REXX

REXX. Objectives. Introduction to REXX Syntax and Functions Advanced Concepts. Introduction. What is REXX ? Restructured EXtended eXecutor Interpreted command language Very useful for linking TSO, ISPF and other functions Useful for developing custom-made utilities. Features of REXX.

eli
Download Presentation

REXX

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. REXX

  2. Objectives • Introduction to REXX • Syntax and Functions • Advanced Concepts

  3. Introduction • What is REXX ? • Restructured EXtended eXecutor • Interpreted command language • Very useful for linking TSO, ISPF and other functions • Useful for developing custom-made utilities

  4. Features of REXX • Ease of use • Free format • Convenient built-in functions

  5. Features of REXX (Cont...) • Debugging capabilities • Interpreted language • Extensive parsing capabilities

  6. Components of REXX • Instructions • Built-in functions • TSO/E external functions • Data stack functions

  7. Instruction • Keyword • Tells the language processor to do something • Assignment • Gives a value to a variable or changes the current value of a variable • Label • A symbolic name followed by a colon • Identifies a portion of the exec • Commonly used in subroutines and functions, and with the SIGNAL instruction

  8. Instruction (Cont...) • Null • Comment or a blank line • Ignored by the language processor • Makes an exec easier to read • Command (both REXX commands and host commands)

  9. Built-in functions • These functions are built into the language processor • Provide convenient processing options

  10. TSO/E external functions • Interact with the system • Do specific tasks for REXX

  11. Data stack functions • Store data for I/O • Other types of processing

  12. Syntax of REXX

  13. Character Type of REXX • A REXX instruction can be in lower case, upper case, or mixed case • Alphabetic characters are changed to uppercase, unless enclosed in single or double quotation marks • The two types of quotation marks cannot be mixed • If any word in the statement is a variable, REXX substitutes the value

  14. Format • REXX uses a free format • A line usually contains one instruction except when it ends with a comma (,) or contains a semi-colon (;). • Comma is the continuation character • Indicates that the instruction continues to the next line • Semi-colon indicates the end of the instruction • Used to separate multiple instructions on one line

  15. Environment / Address • ADDRESS TSO for native TSO commands • ADDRESS ISPEXEC for ISPF services • ADDRESS ISREDIT for ISPF edit macros • These are required to invoke the environment for function calls

  16. Variables and expressions

  17. Variables • Character or group of characters that represents a valuee.g. count = 1000 • Variable names can consist of: • A....Z / a - Z alphabetic • 0....9 numbers • @ # $ ¢ ? ! . _ special characters

  18. Variables (Cont...) • Restrictions on the variable name are: • The first character cannot be 0 through 9 or a period (.) • The variable name cannot exceed 250 bytes • The variable name should not be RC, SIGL, or RESULT, which are REXX special variables

  19. Parsing • Separates data by comparing the data to a template (or pattern of variable names) • Preserves the case of the input data • PARSE UPPER converts data to uppercase • Separators in a template can be • blank, • string, • variable, or • number that represents column position

  20. Parsing • Blank - an example • Each variable name gets one word of data in sequence except for the last, which gets the remainder of the data • PARSE VALUE ‘Value with Blanks.’ WITH pattern type • pattern contains ‘Value’ • type contains ‘ with Blanks.’

  21. Parsing • Blank - another example • PARSE VALUE ‘Value with Extra Variables.’ WITH data1 data2 data3 data4 data5 • data1 contains ‘Value’ • data2 contains ‘with’ • data3 contains ‘Extra’ • data4 contains ‘Variables.’ • data5 contains ‘’

  22. Parsing • Substitution - an example • PARSE VALUE ‘Value with Periods in it.’ WITH pattern . type . • pattern contains ‘Value’ • type contains ‘Periods’ • the periods replace the words “with” and “in it.”

  23. Parsing • Separators - an example • phrase = ‘Dun & Bradstreet’ • PARSE VAR phrase part1 ‘&’ part2 • part1 contains ‘Dun ’ • part2 contains ‘ Bradstreet’

  24. Parsing • Number: Numbers in a template to indicate the column at which data must be separated • Unsigned integer indicates an absolute column position and • Signed integer indicates a relative column position

  25. Parsing • Absolute column position • An unsigned integer or an integer prefixed with an equal sign (=) in a template • The first segment starts at column 1 and goes up to, but does not include, the information in the column number specified • The subsequent segments start at the column numbers specified

  26. Parsing • Absolute column position - an example • quote = ‘Dun & Bradstreet’ • PARSE VAR quote part1 6 part2 • part1 contains ‘Dun &’ • part2 contains ‘Bradstreet’

  27. Parsing • Absolute column position - another example • quote = ‘Dun & Bradstreet’ • PARSE VAR quote part1 5 part2 7 part3 1 part4 • part1 contains ‘Dun’ • part2 contains ‘&’ • part3 contains ‘Bradstreet’ • part4 contains ‘Dun & Bradstreet’

  28. Parsing • Relative column position • A signed integer in a template separates the data according to relative column position • The starting position is relative to the starting position of the preceding part. • Can be either positive (+) or negative (-)

  29. Parsing • Relative column position - an example • quote = ‘Dun & Bradstreet’ • PARSE VAR quote part1 +5 part2 +5 part3 • part1 contains ‘Dun &’ • part2 contains ‘ Brad’ • part3 contains ‘street’

  30. Parsing • Variables • Define and use variables to provide further flexibility of a PARSE VAR instruction • Define the variable prior to the parse instruction • Enclose the variable in parenthesis - this variable must be an unsigned integer • Use a sign outside the parenthesis to indicate how REXX is to interpret the unsigned integer • REXX substitutes the numeric value for the variable

  31. Parsing • Variables - an example • quote = ‘Dun & Bradstreet’ • movex = 4 • PARSE VAR quote part5 +6 part6 +4 part7-(movex) part8 • part5 contains ‘Dun &’ • part6 contains ‘Brad’ • part7 contains ‘street’ • part8 contains ‘Bradstreet’

  32. Expressions • Something that needs to be calculated/evaluated • Consists of numbers, variables, or strings, and one or more operators • Four types of operators • Arithmetic • Comparison • Logical and • Concatenation

  33. Arithmetic Operators • Work on valid numeric constants or on variables that represent valid numeric constants • + Add • - Subtract • -number Negate the number • +number Add the number to 0

  34. Arithmetic Operators (Cont...) • * Multiply • ** Raise a number to a whole number power • / Divide • % Divide and return a whole number without a remainder (quotient only) • // Divide and return the remainder only

  35. Arithmetic Operators - Priority • Priority from maximum to minimum • - + Prefix operators • ** Power (exponential) • * / % // Multiplication and division • + - Addition and subtraction

  36. Comparison operators • Do not return a number value • Return either a true or false response in terms of 1 or 0 respectively • == Strictly Equal • = Equal • > Greater than • < Less than • >= Greater than or equal to • <= Less than or equal to

  37. Comparison operators (Cont...) • \== Not strictly equal • \= Not equal • >< Greater than or less than (same as not equal) • \< Not less than • \> Not greater than

  38. Strictly Equal and Equal Operators • When two expressions are strictly equal, everything including the blanks and case (when the expressions are characters) is exactly the same • When two expressions are equal, they are resolved to be the same

  39. Logical Operators • Return a true (1) or false (0) value when processed • Combine two comparisons and return the true (1) or false (0) value depending on the results of the comparisons • Used in complex conditional instructions • Can act as checkpoints to screen unwanted conditions

  40. Logical Operators (Cont...) • The logical operators are • & ANDReturns 1 if both comparisons are true • | Inclusive ORReturns 1 if at least one comparison is true • && Exclusive ORReturns 1 if only one comparison (but not both) is true • Prefix \ Logical NOTReturns the opposite response

  41. Concatenation operators • Combine two terms into one • Terms can be strings, variables, expressions, or constants • Concatenation can be significant in formatting output

  42. Concatenation operators (Cont...) • blank concatenate terms, one blank in betweene.g. TRUE BLUE result is TRUE BLUE • || concatenate terms, no blanks in betweene.g. “a”||”.b” result is a.b • abuttal concatenate terms, no blanks in betweene.g. per_cent‘%’ if per_cent = 50, result is 50%

  43. Overall Operator Priority • \ ¬ - + Prefix operators • ** Power (exponential) • * / % // Multiply and divide • + - Add and subtract • blank || abuttal Concatenation operators • == = >< Comparison operators • & Logical AND • | && inclusive OR, exclusive OR

  44. Control of program flow

  45. Conditional instructions • Instructions which set up at least one condition in the form of an expression • IF/THEN/ELSE, and • SELECT/WHEN/OTHERWISE

  46. IF construct • Can direct the execution of an exec to one of two choices • IF expression THEN instruction ELSE instruction • for more than one instruction for a condition, begin the set of instructions with a DO and end them with an END

  47. IF construct (Cont...) • IF expression THEN DO instruction instruction ENDELSE DO instruction instruction END

  48. SELECT construct • can direct the execution to one of many choices. • SELECT WHEN expression THEN instruction WHEN expression THEN instruction : OTHERWISE instruction(s)END

  49. SELECT construct • for more than one instruction for a possible path, begin the set of instructions with a DO and end them with an END • However, if more than one instruction follows the OTHERWISE keyword, DO and END are not necessary

  50. Looping instructions • Tell the language processor to repeat a set of instructions • A loop can repeat a specified number of times or • Can use a condition to control repeating • Two types of loops • Repetitive repeat instructions a certain number of times • Conditional use a condition to control repeating

More Related