REXX Language Syntax
Part Three - Challenge #02

Background:

REXX is a program language swiss army knife for z/OS System Programmers and System Administrators

Many large enterprises using z/OS for critical applications will have many internal processes using REXX. Many one time tasks involving a lot of data are commonly accomplished using REXX.

While REXX can be executed interpretively, REXX can be compiled into native machine executable to achieve greater performance for high volume and high frequency requirements. Some application developers discovered REXX and write business applications in REXX.


Best way to become familiar with REXX syntax

Similar to all programming languages, the best way to become familiar with REXX programming language syntax is by using and modifying sample code. The internet and IBM web sites are loaded with REXX code examples. Internet search for 'learn rexx' or 'sample rexx code' will return excellent sources of information. Whenever trying or exploring specific REXX syntax new to you, internet search 'REXX example' the specific REXX syntax or 'how to do .... using REXX'.


REXX Slot Machine

A simulated slot machine written in REXX code is used to expose you to REXX syntax. Each enter changes three windows with a name of a fruit. If the same fruit is in all 3 windows, you win.

  1. You will observe the last window does not have a fruit but displays FRUIT.? which never changes. A problem exists in the REXX code. FRUIT.? is intended to be a variable in the REXX code which should change with each enter. However, FRUIT.? never changes. You will be instructed what to look for in the REXX code to correct the problem.
  2. After correcting the problem related to FRUIT.?, a win results in a problem acknowledging you won. Again, you will be instructed what to look for in the REXX code to correct the second problem.
  3. After correcting the second problem, a message is displayed WINNER !!! - $1,000,000. Your $1,000,000 is to be deposited in a safe. However, you must enter safe box 5 digit safe key number which you do not have. The 5 digit safe key is in the REXX code. To complete the challenge, you must enter the correct 5 digit safe key number.

Challenge:

Get the SLOTS REXX code
  1. dslist rexx
  2. edit rexx partitioned data set
  3. s slots - a new empty member
  4. copy 'zos.mtm2019.public.rexx(slots)'
  5. F3 or save;end
  6. Enter ex to the left of slots to execute the REXX code
    It may be necessary press PA1 function, or Esc key or Alt-Ins to terminate

REXX sources of syntax information

Modify SLOTS REXX code enabling FRUIT.? variable to contain a fruit value
  • Edit member SLOTS in your REXX partitioned data set
  • Line 20 start a do loop
  • Line 24, 26, and 28 sets a VIEW.# variable with a random fruit name value
  • Line 28 fails to follow the REXX code pattern
  • Line 28 requires a modification to correct the problem
  • Once REXX code is modified, execute ex the SLOTS code to validate the correction

Modify SLOTS REXX code to acknowledge a win
  • SLOTS execute displays an error on line 73
  • An additional message is displayed about line 73 with what was expected
  • The problem is a matter of a misspelled REXX action command
  • Edit member SLOTS in REXX
  • Line 73 requires a modification to correct the problem
  • Once REXX code is modified, execute ex the SLOTS code to validate the correction

Review SLOTS REXX code to determine the 5 digit safe deposit box key
  • Edit member SLOTS in REXX
  • Lines 63 thru 78 calculate the correct key
  • If you are able to discipher the REXX arithmetic operations, you have the correct key
  • If you really struggle with the REXX arithmetic operations to determine correct key, look at line 81
  • Execute ex the SLOTS code providing the correct 5 digit key to collect winnings
  • View p3.output member #02 for winnings deposited


By the way, if you're having trouble with the REXX arithmetic, we have Jeanne Glass from VirtualZ Computing with a hint.


You have some familiarity with REXX, a swiss army knife program language used by many z/OS System Programmers and System Administrators.

Next: Challenge #03