Congratulations!
Now you know the best ways to program your REXX execs. Have fun writing programs
that will make your life easier!
/********************************************************/
/* SAMPLE #3:
A portion of CATMOUSE EXEC
*/
/* divided into segments and written with 'more'
*/
/* indentation and 'more' comments.
*/
/* Note commands in uppercase (to highlight logic)
*/
/********************************************************/
/********************************************************/
/* Main program
*/
/********************************************************/
DO FOREVER
CALL display
/**********************************/
/* Mouse's turn
*/
/**********************************/
PULL move
IF datatype(move,whole) & move >= 0 & move <=2
THEN SELECT
WHEN mouse+move > len
/* mouse hits wall */
THEN nop
/* and loses turn
*/
WHEN cat > mouse,
& mouse+move >= cat, /* mouse hits cat
*/
THEN mouse = cat
/* and loses game
*/
OTHERWISE mouse = mouse + move /* mouse ...
*/
END
/* moves to new location */
IF mouse = hole THEN LEAVE
/* mouse is home safely
*/
IF mouse = cat
THEN LEAVE
/* mouse hits cat (ouch) */
/**********************************/
/* Cat's turn
*/
/**********************************/
jump = RANDOM(1,spring)
/* determine cat's move
*/
IF cat > mouse
/* cat must jump left
*/
THEN DO
IF cat-jump < 1
/* cat hits wall
*/
THEN nop
/* misses turn
*/
ELSE cat = cat-jump
/* cat jumps left
*/
END
ELSE DO
/* cat must jump right
*/
IF cat+jump > len
/* cat hits wall
*/
THEN nop
/* misses turn
*/
ELSE cat = cat+jump
/* cat jumps right
*/
END
IF cat = mouse THEN LEAVE
/* cat catches mouse
*/
END
/********************************************************/
/* Conclusion
*/
/********************************************************/
CALL display
/* on final display */
IF cat = mouse
/* who won?
*/
THEN say "Cat wins"
/* ... the cat
*/
ELSE say "Mouse wins"
/* ... the mouse
*/
EXIT
Programming Style and Techniques
Chapter 10. Programming Style and Techniques
99
Summary of Contents for SC34-5764-01
Page 1: ...CICS Transaction Server for VSE ESA REXX Guide SC34 5764 01...
Page 2: ......
Page 3: ...CICS Transaction Server for VSE ESA REXX Guide SC34 5764 01...
Page 22: ...xx CICS TS for VSE ESA REXX Guide...
Page 23: ...Part 1 User s Guide Copyright IBM Corp 1992 2009 1...
Page 24: ...2 CICS TS for VSE ESA REXX Guide...
Page 40: ...18 CICS TS for VSE ESA REXX Guide...
Page 54: ...Using Variables and Expressions 32 CICS TS for VSE ESA REXX Guide...
Page 106: ...84 CICS TS for VSE ESA REXX Guide...
Page 110: ...88 CICS TS for VSE ESA REXX Guide...
Page 122: ...100 CICS TS for VSE ESA REXX Guide...
Page 123: ...Part 2 Reference Copyright IBM Corp 1992 2009 101...
Page 124: ...102 CICS TS for VSE ESA REXX Guide...
Page 130: ...Introduction 108 CICS TS for VSE ESA REXX Guide...
Page 152: ...REXX General Concepts 130 CICS TS for VSE ESA REXX Guide...
Page 224: ...Functions 202 CICS TS for VSE ESA REXX Guide...
Page 252: ...230 CICS TS for VSE ESA REXX Guide...
Page 278: ...256 CICS TS for VSE ESA REXX Guide...
Page 312: ...DB2 Interface 290 CICS TS for VSE ESA REXX Guide...
Page 316: ...High level Client Server Support 294 CICS TS for VSE ESA REXX Guide...
Page 340: ...318 CICS TS for VSE ESA REXX Guide...
Page 344: ...for execs Commands 322 CICS TS for VSE ESA REXX Guide...
Page 399: ...Part 3 Appendixes Copyright IBM Corp 1992 2009 377...
Page 400: ...378 CICS TS for VSE ESA REXX Guide...
Page 438: ...416 CICS TS for VSE ESA REXX Guide...
Page 442: ...System Definition Customization Administration 420 CICS TS for VSE ESA REXX Guide...
Page 446: ...Security 424 CICS TS for VSE ESA REXX Guide...
Page 448: ...426 CICS TS for VSE ESA REXX Guide...
Page 464: ...442 CICS TS for VSE ESA REXX Guide...
Page 466: ...444 CICS TS for VSE ESA REXX Guide...
Page 468: ...446 CICS TS for VSE ESA REXX Guide...
Page 476: ...454 CICS TS for VSE ESA REXX Guide...
Page 478: ...456 CICS TS for VSE ESA REXX Guide...
Page 479: ......
Page 480: ...SC34 5764 01...
Page 481: ...Spine information CICS TS for VSE ESA REXX Guide...