Rexx Primer -1

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Rexx Primer -1 as PDF for free.

More details

  • Words: 822
  • Pages: 3
Quick REXX Part I By Alok Devtale

1. REXX procedure will be written in a member of a PDS having LRECL=80 (FB). REXX is an interpreted language. So, you don't compile REXX. Just code it and run it. You can type "EX" in front of the member to RUN the REXX procedure. Or you can use the following command anywhere in TSO TSO EXEC 'rexx lib(rexx member)' EXEC e.g. to run the REXX procedure stored in a member PDS1.REXXLIB(REXX1) you should write TSO EXEC 'PDS1.REXXLIB(REXX1)' EXEC There are simpler ways of running REXX procedures. But, that will be covered later! 2. The first line of a REXX procedure is /*REXX*/ 3. Comments are coded between "/*" and "*/". This is effective only for a line. e.g. /* This is a comment */ 4. If you want to display something use: SAY argument where, argument = variable or actual string to be displayed (with or without quotes) e.g. SAY Hello World! or VAR1= "Hello World!" SAY VAR1 or SAY "HELLO WORLD!" In all the three cases the output will be HELLO WORLD! 5. To give TSO commands: ADDRESS TSO "tso command" e.g. ADDRESS TSO "ALLOCATE DD(INFILE) DSN('R1LTWB.ALOK.GENERAL') USAGE SHR" Once ADDRESS TSO command is issued, anything after that line in double quotes will be treated as TSO command until next ADDRESS command appears. 6. Variables are not declared. Their type depends on the value put in them. Values are assigned to variables using "=" sign. e.g.

VAR1 = 10 will make VAR1 a numeric. Immediately if you write VAR1 = "HAHAHA" it will be treated as a string. So, the code VAR1 = 10 VAR1 = VAR1 + 10 will work fine But, the code VAR1 = "HAHAHA" VAR1 = VAR1 + 10 will fail. 7. You can concatenate two strings by "||". e.g. VAR1 = "HE LAUGHED " VAR2 = "HA HA HA" VAR3 = "!" SAY VAR1||VAR2||VAR3 will produce HE LAUGHED HA HA HA! While concatenating, any variable will be treated as string e.g. VAR1 = 10 VAR2 = " is a number!" SAY VAR1||VAR2 will produce 10 is a number! You can concatenate literals and variables. e.g VAR1 = "THIS " SAY VAR1||"WORKS!" will produce THIS WORKS! even, SAY VAR1||WORKS! will produce the same result. Concatenation using "||" is a very useful feature. Experiment with this feature a lot! 8. Arrays are also very easy to use. Any variable with a period after its name becomes a array. You don't have to declare it or mention how many elements it will have or what will be data type or length of each element. Having multidimensional arrays is also easy. e.g. ARRAY1. is an array. you can start putting values in this array by using subscripts. ARRAY1.1 = 10 ARRAY1.2 = 20

VAR1 = 3 ARRAY1.VAR1 = 30 So, the code DO I = 1 BY 1 UNTIL I = 3 SAY ARRAY1.I END will produce following output 10 20 30 ARRAY1. = "" will initialize the array! You can start from the 0th element. But it is better to start from 1st element, as the 0th element is automatically populated by number of elements in the array when the array is used for storing output of system commands like TSO commands. This will be covered later. ARRAY2.VAR1.VAR2 is a multidimensional array. Here, ARRAY2. is a single dimensional array and ARRAY2.VAR1. is another single dimensional array. Both working together we get a 2 dimensional array. Try it out. 9. One more thing useful at this stage will be the PARSE command. For now we will use it to accept values from user. e.g. to read value entered by the user on screen following syntax can be used PARSE EXTERNAL VAR1 PARSE is the main verb and EXTERNAL is one of its many parameters. So, a simple program like the following will make you nostalgic about C programming! SAY "Please enter your name:" PARSE EXTERNAL NAME1 SAY NAME1 Now that you know little bit of REXX why not give it a try. As a self assignment write a simple REXX procedure to allocate a new flat file after accepting the name from user. For this you need to know a simple TSO command which is used to allocate datasets. The command is ALLOCATE and this is how it will work: ALLOCATE DDNAME(ddname) DSNAME('name of the dataset') LRECL(n) RECFM(F,B) BLKSIZE(m) where DDNAME is the ddname to which the dataset will be assigned. Don't worry about it right now. Everything else in the command is self explanatory. Another TSO command you may need is FREE FREE DDNAME(ddname) This will free the ddname that you assigned using the ALLOCATE command and in tern will free the dataset. Note that this is a TSO command and will need concatenation. Do contact me if you are stuck or have suggestions about this document. The next part will be reaching you as soon as I am done typing.

Related Documents

Rexx Primer -1
June 2020 2
Rexx Primer - 2
June 2020 2
Rexx
November 2019 24
Rexx
November 2019 25
Rexx-vse
November 2019 20
Rexx Training
November 2019 17