Tip

Take a break from your work and increase your productivity

Relax by executing this Game procedure written in REXX.(!!!) (Enter the command STRREXPRC SRCMBR() SRCFILE(/) to start the game)

I thought that this program I wrote would help someone learn REXX. Note that REXX uses an interpreter instead of a compiler. This may cause run-time issues even for incorrect syntax.

Good luck with REXX.!!!

This program basically makes the user of think of a number between 00 to 99 and prompts the user to specify whether that particular number is displayed in the list or not. It makes the user answer 8 questions and gives the number guessed.

The Way the numbers are displayed is basically based on BCD(Binary Coded Decimal) technique with some alterations.


 call initialize
call display1
   rc = 0
   do  until rc = 1
       parse upper pull game_value
       call check1
       if rc = 0 then say 'Invalid Value. Type Y or N and Press '
   end
call display2
   rc = 0
   do  until rc = 1
       parse upper pull game_value
       call check2
       if rc = 0 then say 'Invalid Value. Type Y or N and Press '
   end
call display3
   rc = 0
   do  until rc = 1
       parse upper pull game_value
       call check3
       if rc = 0 then say 'Invalid Value. Type Y or N and Press '
   end
call display4
   rc = 0
   do  until rc = 1
       parse upper pull game_value
       call check4
       if rc = 0 then say 'Invalid Value. Type Y or N and Press '
   end
call display5
   rc = 0
   do  until rc = 1
       parse upper pull game_value
       call check5
       if rc = 0 then say 'Invalid Value. Type Y or N and Press '
   end
call display6
   rc = 0
   do  until rc = 1
       parse upper pull game_value
       call check6
       if rc = 0 then say 'Invalid Value. Type Y or N and Press '
   end
call display7
   rc = 0
   do  until rc = 1
       parse upper pull game_value
       call check7
       if rc = 0 then say 'Invalid Value. Type Y or N and Press '
   end
call display8
   rc = 0
   do  until rc = 1
       parse upper pull game_value
       call check8
       if rc = 0 then say 'Invalid Value. Type Y or N and Press '
   end
call displayr

exit

initialize:
   low    = 0
   high   = 0
   result = 0
   say 'Guess a number between 00 and 99.......'
   say 'and then Press  to start the game.'
   parse upper pull game_value
return

display1:
   say '08 09 18 19 28 29 38 39 48 49 58 59 68 69 78 79 88 89 98 99'
   say 'Type Y if your guess is in the above list. Otherwise type N'
return
Check1:
   rc = 1
   if game_value = 'Y' then low = low + 8
   else if game_value = 'N' then low = low + 0
   else rc = 0
return
display2:
   say '02 03 06 07 12 13 16 17 22 23 26 27 32 33 36 37 42 43 46 47 52'
   say '53 56 57 62 63 66 67 72 73 76 77 82 83 86 87 92 93 96 97'
   say 'Type Y if your guess is in the above list. Otherwise type N'
return
Check2:
   rc = 1
   if game_value = 'Y' then low = low + 2
   else if game_value = 'N' then low = low + 0
   else rc = 0
return
display3:
   say '01 03 05 07 09 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41'
   say '43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83'
   say '85 87 89 91 93 95 97 99'
   say 'Type Y if your guess is in the above list. Otherwise type N'
return
Check3:
   rc = 1
   if game_value = 'Y' then low = low + 1
   else if game_value = 'N' then low = low + 0
   else rc = 0
return
display4:
   say '04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37 44 45 46 47 54'
   say '55 56 57 64 65 66 67 74 75 76 77 84 85 86 87 94 95 96 97'
   say 'Type Y if your guess is in the above list. Otherwise type N'
return
Check4:
   rc = 1
   if game_value = 'Y' then low = low + 4
   else if game_value = 'N' then low = low + 0
   else rc = 0
return
display5:
   say '80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99'
   say 'Type Y if your guess is in the above list. Otherwise type N'
return
Check5:
rc = 1
   if game_value = 'Y' then high = high + 8
   else if game_value = 'N' then high = high + 0
   else rc = 0
return
display6:
   say '20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 60'
   say '61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79'
   say 'Type Y if your guess is in the above list. Otherwise type N'
return
Check6:
   rc = 1
   if game_value = 'Y' then high = high + 2
   else if game_value = 'N' then high = high + 0
   else rc = 0
return
display7:
   say '10 11 12 13 14 15 16 17 18 19 30 31 32 33 34 35 36 37 38 39 50'
   say '51 52 53 54 55 56 57 58 59 70 71 72 73 74 75 76 77 78 79 90 91'
   say '92 93 94 95 96 97 98 99'
   say 'Type Y if your guess is in the above list. Otherwise type N'
return
Check7:
   rc = 1
   if game_value = 'Y' then high = high + 1
   else if game_value = 'N' then high = high + 0
   else rc = 0
return
display8:
   say '40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60'
   say '61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79'
   say 'Type Y if your guess is in the above list. Otherwise type N'
return
Check8:
   rc = 1
   if game_value = 'Y' then high = high + 4
   else if game_value = 'N' then high = high + 0
   else rc = 0
return
displayr:
   result = high*10 + low
   'RTVJOBA',
   '  USER(&user_id)'
   'RTVUSRPRF',
   '  TEXT(&user_text)'
   user_id_text = strip( user_text )
   user_id_text = word( user_text, 1 )
   if result >= 00 and <= 99 Then

   say 'Hello' user_id_text', your guess is' result

   else

   say 'Hello' user_id_text', you did not answer all the questions
correctly' return 

This was first published in May 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.