Note: Some people find it less confusing when adding elements in a particular
order to the data stack, to consistently use the same instruction, either
PUSH or QUEUE, but not both.
Removing Elements from the Stack
To remove information from the data stack, use the PULL and PARSE PULL
instructions, the same instructions used previously in this book to extract
information from the terminal. (When the data stack is empty, PULL removes
information from the terminal.)
PULL and PARSE PULL - remove one element from the top of the data stack.
PULL stackitem
Using the examples from “Adding Elements to the Data Stack” on page 136, the
variable stackitem then contains the value of elem1 with the characters
translated to uppercase.
SAY stackitem /* displays STRING 1 FOR THE DATA STACK */
When you add PARSE to the preceding instruction, the value is not translated to
uppercase.
PARSE PULL stackitem
SAY stackitem /* displays String 1 for the data stack */
After either of the preceding examples, the data stack appears as follows:
Determining the Number of Elements on the Stack
The QUEUED built-in function returns the total number of elements on a data stack.
For example, to find out how many elements are on the data stack, you can use the
QUEUED function with no arguments.
SAY QUEUED() /* displays a decimal number */
To remove all elements from a data stack and display them, you can use the
QUEUED function as follows:
Manipulating the Data Stack
Chapter 11. Storing Information in the Data Stack 137