User`s guide

4-17
Printer, Plotter, and Spooler Subsystem Programming
Note: The first value to be popped off the stack is the last one to be pushed onto the stack,
and the second value to be popped off the stack is the one that was pushed onto the
stack first.
Bitwise Logical Operators:
%& %| %^ %~ Pushes the result onto the stack.
%& ANDs the first two values popped off the stack. For example,
%{6}%{3}%& pushes a value of 2 onto the stack.
%| ORs the first two values popped off the stack. For example,
%{6}%{3}%| pushes a value of 7 onto the stack.
%^ EXCLUSIVE ORs the first two values popped off the stack. For
example, %{6}%{3}%^ pushes a value of 5 onto the stack.
%~ ONE’S COMPLEMENTs the first value popped off the stack and inverts
the value of each bit. For example, %{–1}%~ pushes a value of 0 (all
bits off) onto the stack (assumes two’s complement notation for –1).
Conditional (if–then–else) Operators:
%? expr %t
thenpart %e
elsepart %;
%t pops a value off the stack and tests it. If the value is TRUE
(nonzero), thenpart is run. Otherwise, elsepart (if present) is run.
else–if construct
%? c1 %t b1 %e c2 %t b2 %e c3 %t b3 %e b4 %;
where c1, c2, c3 denote conditions and b1, b2, b3, b4 denote bodies. For example,
%?%{1}%t%{2}%e%{3}%; pushes a value of 2 onto the stack, and
%gx%{6}%?%=%t%{2}%e%{3}%;%d outputs a value of 2 if the value of the internal
variable x is 6. If value of x is not 6, a value of 3 is output.
When developing complex logic, it is sometimes useful to show it in structured form. The
preceding example, in structured form, might look like this:
%gx Pushes the value of x onto the stack
%{6} Pushes a value of 6 onto the stack
%?%=%t If the stack values are equal then
%{2} pushes a value of 2 onto the stack
%e else
%{3} pushes a value of 3 onto the stack
%; endif
%d Outputs
the value in
ASCII format
Pass–through:
%x (The piocmdout subroutine call only.) Pass through from input to output
the number of bytes specified by the passthru argument to the
piocmdout subroutine.