Macro Language Reference > PIs > Text > <?queue>
  
<?queue>
Description
The <?queue> command enables you to insert text and/or processing instructions at the start of the current and following lines. The text will be inserted just after gathering all the format information for the current line, i.e. after the paragraph style etc, but before any text that forms part of the line. The <?queue> command is similar to line or paragraph references, but instead of having to be attached to a frame, <?queue> can be attached to styles or used inline anywhere within a paragraph. Text can be made to repeat a fixed or infinite number of times and is used only within paragraph boundaries. Several queues can be run concurrently and independently of each other, by giving each queue a number from 1 to 10.
 
Example 485. Format a paragraph with the <?queue> command
The example below demonstrates a basic use of the queue command.It specifies that an 'x' will appear at the start of the first line of the paragraph and a 'y' will appear at the start of the second line.
<?queue "x","y">
 
Example 486. Add items to a queue
The following example adds another item to the start of the next line in queue one:
<?queue -[1] "x">
The next example adds another item to the end of the next line in queue one:
<?queue +[1] "y">
 
Example 487. Use multiple queues
The following sytax will use 2 queues to insert the following on the next six lines: "ab","ac","ac","ad","a"
<?queue [2]"b",2"c","d"><?[1]5"a">
The index usually controls the order in which the strings are inserted. It is also possible to run the second queue in the index first, as shown in the above example.
 
Example 488. Override existing queues
Existing queues can be overridden, simply by specifying a new value for the queue. To deactivate a queue prematurely, simply specify a new <?queue> command with no value. For example, to deactivate the second queue, use the following syntax:
<?queue [2]>
 
Example 489. Use repeat counts in conjunction with brackets
<?queue (5"a","b")>
output: "a","b","a","b","a","b","a","b","a","b"
<?queue 2("a", 2("b", 2"c"))>
output: "a","b","c","c","b","c","c","a","b","c","c","b","c","c"
 
Example 490. Set paragraph boundaries for a queue
A queue usually crosses paragraph boundaries, but in this example a single p parameter is used to limit the queue to the current paragraph:
<?queue p("a","b")>
To limit the queue to a specific number of paragraphs (in this example, 7), use the following syntax:
<?queue 7p("a","b")>
 
Example 491. Format the last line of a paragraph with the <?queue> command
The example below demonstrates how the <?queue> command can recognize the last line of a paragraph and insert an alternative string in its place. The letter 'a' will be inserted at the start of the first line. The last parameter has an l in front of it to specify that the 'b' should always appear at the start of the last line (even if all the items in the current queue have not been applied by the time the last line appears). :
<?queue p("a",l"b">
 
Example 492. Format the last line of a paragraph with the <?queue> command (2)
Using the <?queue> syntax shown below it is possible to ensure the specified string is included in the paragraph. The uppercase 'L' will insert a 'd' on the last line if there are not enough lines. If all the items have been used, however, the 'd' will appear on the next line after the 'c', instead of on the last line :
<?queue p("a","b","c",L"d">
 
Example 493. Use showstring 'x' counters with the queue command
The <?queue> syntax can also make use of show string functionality. This enables the use of processing instructions and 'x' counters. In this example, the first queue will only appear on the first paragraph, while the second queue will appear on every line of every paragraph:
<?queue [1]"=0x(1)"><?queue [2]"+x(1)$x(1)"*>
 
Example 494. Apply processing instructions with the <?queue> command
It is possible to apply processing instructions in the same way as when using show strings. The example below will make text in both the current and the next line red.
<?queue "[?tic red]","","[?tic]">
Syntax
<?queue ( ( '+' '-' )? )? ( '[' num:n ']' )?> itemlist:
Where the syntax for an <itemlist> is as follows:
<itemlist>
<item> (<item>)*
<item>
(<pitem>)? (<ritem> | <litem>)
<pitem>
(repeat:n)? (p | p*)
<ritem>
(repeat:n)? (<sitem> | <sitem>*)
<sitem>
string:s | (<itemlist>)
<litem>
'l' string:s | 'L' string:s
+
Appends a new itemlist to the end of an existing queue.
See example: Adding Items to a Queue
-
Inserts a new itemlist in front of the original items.
num
Specifies the queue number. Multiple queues can be specified by including an index at the start of the <?queue> command, ranging from 1 to 10. These queues will then be used concurrently and independently. If you do not specify an index, then queue number 1 will be used automatically.
See example: Using Multiple Queues.
See example: Overriding Queues.
itemlist
Defines the syntax for the list of items that you want to queue.
item
Specifies the type of item that you want in the itemlist.
pitem
The paragraph item and an optional repeat parameter, along with the literal characters p or p*.
ritem
Contains either the optional repeat parameter or repeat instances of sitem, also optional.
sitem
Requires a string parameter or a litem parameter group.
litem
Requires string parameter(s) preceded by the literal characters l or L.
repeat
Specifies the number of times you require the p and sitem parameters to be repeated: a number greater than zero. The repeat parameter specifies the number of lines to which each string should be applied. For example, <?queue 5"a","2"b> will insert a on the current line and the next four lines, and then insert b on the two subsequent lines.
See example: Using repeat counts in conjunction with brackets.
string
Allocates the text / PI / show string to be inserted. Can contain any string of alphanumeric characters.
p
Putting a p in front of an item means the pitem is restricted to a paragraph.
When a pitem is used, it means two things:
When the paragraph ends, any remaining items within the p are discarded ready for the next paragraph.
If the items within the pitem run out before the end of the paragraph, nothing further will be extracted from the queue until the end of the paragraph is reached.
See example: Specifying Queue Paragraph Boundaries
l
In addition, the <?queue> command can also be configured to recognize the last line of a paragraph and insert an alternative string there. This is done by placing either a l or L parameter in front of a string, but is only relevant within a pitem. These both work by reformatting the last line of the paragraph with the relevant string. The l parameter formats as the last string for the paragraph. Even if it is encountered earlier in the paragraph PTC ALD inserts it on the last line.
See example: Last Line Formatting with a Queue.
L
Ensures the string is included within the paragraph. If the queue gets to the last line of the paragraph and the string has not yet been inserted, it is inserted now.
See example: Last Line Formatting with a Queue (2).
*
It is possible to add the string ad-infinitum by adding a * after the string. For example, <?queue "a"*> adds an 'a' at the start of every line following the point of insertion. This also repeats across paragraph boundaries.
Additional information
Getvars
Three getvars enable you to interrogate the current queues:
Getvar 11657 gives the current queue list.
Getvar 11658 gives the next queue list.
Getvar 11659 gives the current queue item that was inserted.
Each of the getvars takes an optional index to enable access to an individual queue. If the index is 0 (or unspecified), they return a list of the queues for which the relevant information is available.
 
Getvar 11658 returns the queue list for the next line, as it currently stands. If the current line is the last in a paragraph, then this may subsequently change. Getvar 11659 returns the item inserted in the line. If an l or L parameter option were used PTC ALD can format the line twice, once with the old string and once with the new one.
For more information on getvars, see getvar and Reference Chapter: System Variables.
The <?queuex> command
The <?queuex> command permits you to pause or resume a queue, or skip an item from the output of the queue. See <?queuex> for further details of this command.
For more information, see Reference Chapter: System Variables.
Related Links