IBM SC34-5764-01 Manual page 120

Cics transaction server for vse/esa
Table of Contents

Advertisement

Programming Style and Techniques
/********************************************************/
/* SAMPLE #2: A portion of CATMOUSE EXEC
/* divided into segments and written with 'some'
/* indentation and 'some' comments.
/********************************************************/
/********************************************************/
/* 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,
then mouse = cat
otherwise
mouse = mouse + move
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
This next example has additional features that are popular with some programmers. Keywords written in
uppercase and a different indentation style highlight the structure of the code; the abundant comments
recall the detail of the specification.
98
CICS TS for VSE/ESA: REXX Guide
/* hits wall */
/* hits cat */
/* moves
/* reaches hole */
/* hits cat
/* cat tries to jump left */
/* hits wall */
/* cat tries to jump right */
/* hits wall */
*/
*/
*/
*/
*/
*/
*/
*/
*/

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Rexx

Table of Contents