EasyManuals Logo

IBM TSO/E REXX User Manual

IBM TSO/E REXX
242 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #156 background imageLoading...
Page #156 background image
number = QUEUED()
DO number
PULL element
SAY element
END
Exercise - Using the Data Stack
Write an exec that puts the letters T, S, O, E on the data stack in such a way that
they spell TSOE when removed. Use the QUEUED built-in function and the PULL
and SAY instructions to help remove the letters and display them. To put the letters
on the stack, you can use the REXX instructions PUSH, QUEUE, or a combination
of the two.
ANSWER
Possible Solution 1
/******************************** REXX *****************************/
/* This exec uses the PUSH instruction to put the letters T,S,O,E,*/
/* on the data stack in reverse order. */
/*******************************************************************/
PUSH 'E' /**************************/
PUSH 'O' /* Data in stack is: */
PUSH 'S' /* (fourth push) T */
PUSH 'T' /* (third push) S */
/* (second push) O */
number = QUEUED() /* (first push) E */
DO number /**************************/
PULL stackitem
SAY stackitem
END
Possible Solution 2
/******************************** REXX *****************************/
/* This exec uses the QUEUE instruction to put the letters T,S,O,E,*/
/* on the data stack in that order. */
/*******************************************************************/
QUEUE 'T' /***************************/
QUEUE 'S' /* Data in stack is: */
QUEUE 'O' /* (first queue) T */
QUEUE 'E' /* (second queue) S */
/* (third queue) O */
DO QUEUED() /* (fourth queue) E */
PULL stackitem /***************************/
SAY stackitem
END
Manipulating the Data Stack
138
z/OS V1R1.0 TSO/E REXX Users Guide

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the IBM TSO/E REXX and is the answer not in the manual?

IBM TSO/E REXX Specifications

General IconGeneral
BrandIBM
ModelTSO/E REXX
CategoryComputer Hardware
LanguageEnglish

Related product manuals