Original Author Paul Laughton, 2011
Page 51
De Re BASIC!
There is no fixed limit on the size or number of stacks. You are limited only by the memory of your
device.
Stack Commands
Stack.create N|S, <ptr_nvar>
Creates a new stack of the designated type (N=Number, S=String). The stack pointer is in <ptr_nvar>.
Stack.push <ptr_nexp>, <nexp>|<sexp>
Pushes the <nexp> or <sexp> onto the top of the stack designated by <ptr_nexp>.
The type of value expression pushed must match the type of the created stack.
Stack.pop <ptr_nexp>, <nvar>|<svar>
Pops the top-of-the-stack value designated by <ptr_nexp> and places it into the <nvar> or <svar>.
The type of the value variable must match the type of the created stack.
Stack.peek <ptr_nexp>, <nvar>|<svar>
Returns the top-of-stack value of the stack designated by <ptr_nexp> into the <nvar> or <svar>. The
value will remain on the top of the stack.
The type of the value variable must match the type of the created stack.
Stack.type <ptr_nexp>, <svar>
The type (numeric or string) of the stack designated by <ptr_nexp> will be returned in <svar>. If the
stack is numeric, the upper case character "N" will be returned. If the stack is a string stack, the upper
case character "S" will be returned.
Stack.isEmpty <ptr_nexp>, <nvar>
If the stack designated by <ptr_nexp> is empty the value returned in <nvar> will be 1. If the stack is not
empty the value will be 0.
Stack.clear <ptr_nexp>
The stack designated by <ptr_nexp> will be cleared.
Queues
A Queue is like the line that forms at your bank. When you arrive, you get in the back of the line or
queue. When a teller becomes available the person at the head of the line or queue is removed from the
queue to be serviced by the teller. The whole line moves forward by one person. Eventually, you get to
the head of the line and will be serviced by the next available teller. A queue is something like a stack
except the processing order is First In First Out (FIFO) rather than LIFO.
Using our customer order processing analogy, you could create a queue of order bundles for the order
processing department. New order bundles would be placed at the end of the queue. The top-of-the-