The external data queue is a sequence of strings that are stored internally within the Rexx environment. All data queue interactions are simple line interactions. When Rexx passes control to commands, these commands may add lines to the external data queue, or extract lines from the data queue.
Rexx programs interact with the data queue with the following instructions.
|parse pull||extracts the most recently pushed line|
|push||pushes the line to be extracted next|
|queue||queues a line to be extracted last|
|pull||an abbreviation of parse upper pull|
When no lines remain in the data queue, the parse pull instruction reads a line from the default input stream instead.
The number of lines in the data queue can be determined by using the queued built-in function.
The following is an example of a program that uses data queue facilities.
/* prepare a sequence of programs to process */ queue 'Program1 -- main program' queue 'Subprog1 -- subprogram 1' queue 'Subprog2 -- subprogram 2' programs = '' do queued() parse pull program . 'cc' program'.c' if rc <> 0 then do say 'An error occurred while compiling' program'.c ...' rc exit 1 end programs = programs program'.obj' end 'link /out:Module.exe' programs if rc <> 0 then do say 'An error occurred while linking Module.exe ... code:' rc exit 1 end exit 0
Portability note: other Rexx implementations use the following additional data queue capabilities: