- Rexx - Web Programming
- Rexx - Reginald
- Rexx - Graphical User Interface
- Rexx - Best Programming Practices
- Rexx - Performance
- Handheld & Embedded
- Rexx - Databases
- Rexx - Brexx
- Rexx - Netrexx
- Rexx - Implementations
- Rexx - Instructions
- Rexx - Extended Functions
- Rexx - Portability
- Rexx - Object Oriented
- Rexx - Error Handling
- Rexx - Debugging
- Rexx - Signals
- Rexx - Parsing
- Rexx - Regina
- Rexx - XML
- Rexx - System Commands
- Rexx - Built-In Functions
- Rexx - Subroutines
- Rexx - Functions For Files
- Rexx - File I/O
- Rexx - Stacks
- Rexx - Functions
- Rexx - Strings
- Rexx - Numbers
- Rexx - Decision Making
- Rexx - Loops
- Rexx - Arrays
- Rexx - Operators
- Rexx - Variables
- Rexx - Datatypes
- Rexx - Basic Syntax
- Rexx - Installation of Plugin-Ins
- Rexx - Installation
- Rexx - Environment
- Rexx - Overview
- Rexx - Home
Rexx Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Rexx - Stacks
The stack is sometimes called the external data queue, but we follow common usage and refer to it as the stack. It is a block of memory that is logically external to Rexx. Instructions pke push and queue place data into the stack, and instructions pke pull and parse pull extract data from it. The queued built-in function reports how many items are in the stack.
Let’s take a look at an example of a stack.
/* STACK: */ /* */ /* This program shows how to use the Rexx Stack as either a */ /* stack or a queue. */ do j = 1 to 3 push ‘Stack: pne #’ || j /* push 3 pnes onto the stack */ end do j = 1 to queued() /* retrieve and display LIFO */ pull pne say pne end do j = 1 to 3 queue ‘Queue: pne #’ || j /* queue 3 pnes onto the stack */ end do queued() /* retrieve and display FIFO */ pull pne say pne end exit 0
The first do loop in the program places three pnes of data onto the stack. It uses the push instruction to do this. We number the pnes so that when they are retrieved in the LIFO order their order is apparent.
The items placed into the stack by the push instruction are retrieved in the LIFO order −
do j = 1 to 3 push ‘Stack: pne #’ || j /* push 3 pnes onto the stack */ end
The next code block shows the use of the queued built-in function to discover the number of pnes on the stack, as well as a loop to retrieve all the pnes from the stack −
do j = 1 to queued() /* retrieve and display LIFO */ pull pne say pne end
Since the three items were placed on the stack via push, they are retrieved in the LIFO order.
The output of the above program will be as follows.
STACK: LINE #3 STACK: LINE #2 STACK: LINE #1Advertisements