IBM SC34-5764-01 Manual page 121

Cics transaction server for vse/esa
Table of Contents

Advertisement

/********************************************************/
/* 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
THEN nop
WHEN cat > mouse,
& mouse+move >= cat, /* mouse hits cat */
THEN mouse = cat
OTHERWISE mouse = mouse + move /* mouse ... */
END
IF mouse = hole THEN LEAVE
IF mouse = cat THEN LEAVE
/**********************************/
/* Cat's turn
/**********************************/
jump = RANDOM(1,spring)
IF cat > mouse
THEN DO
IF cat-jump < 1
THEN nop
ELSE cat = cat-jump
END
ELSE DO
IF cat+jump > len
THEN nop
ELSE cat = cat+jump
END
IF cat = mouse THEN LEAVE
END
/********************************************************/
/* Conclusion
/********************************************************/
CALL display
IF cat = mouse
THEN say "Cat wins"
ELSE say "Mouse wins"
EXIT
Congratulations! Now you know the best ways to program your REXX execs. Have fun writing programs
that will make your life easier!
*/
/* mouse hits wall */
/* and loses turn */
/* and loses game */
/* moves to new location */
/* mouse is home safely */
/* mouse hits cat (ouch) */
*/
/* determine cat's move */
/* cat must jump left
/* cat hits wall
/* misses turn
/* cat jumps left
/* cat must jump right
/* cat hits wall
/* misses turn
/* cat jumps right */
/* cat catches mouse
/* on final display */
/* who won?
/* ... the cat
/* ... the mouse
Programming Style and Techniques
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
Chapter 10. Programming Style and Techniques
99

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Rexx

Table of Contents