next up previous contents
Next: gprintf Up: APrintf Previous: APrintf   Contents

Effect and Restrictions

Effect:
In a pseudocode notation, the general behaviour of aprintf() is like

$\displaystyle \begin{minipage}[t]{\linewidth}\small\begin{tabbing}
\verb$for e...
......, $$i_{R-1}$\verb$],$ \\
\>\verb$...)$ \\
\end{tabbing}
\end{minipage}
$

where $ (N_0, \ldots, N_{R-1})$ is the shape the arrays. The integer value $ i_0$ is interpolated into the output wherever there is a %R0 in the control string; the value $ i_1$ is interpolated wherever there is a %R1; and so on. The imaginary elemental printf operation outputs to System.out on the root process of the active process group.
Special options:
%R$ D$:
It prints the current index value. $ D$ stands for integer number like %R0, %R1, and so on. The format %R$ D$ interpolates the index value into the string without the need to initialize an extra array of integer. Example:

$\displaystyle \begin{minipage}[t]{\linewidth}\small\begin{verbatim}
float [[-,-...
...a [1, 0] = 10.0
a [1, 1] = 11.0
a [1, 2] = 12.0\end{verbatim}\end{minipage}
$

%N:
It provides line breaking. It behaves exactly like the \n escape sequence. But %N allow an integer modifier. It defines the frequency with which the newline is printed. If the value of the modifier is $ w$, the new line is only printed in every $ w$th elemental print operation. Example: If we replace the aprintf() call in the previous example with

$\displaystyle \begin{minipage}[t]{\linewidth}\small\begin{verbatim}
Adlib.aprin...
...
a [1, 0] = 10.0 a [1, 1] = 11.0 a [1, 2] = 12.0\end{verbatim}\end{minipage}
$

Shape restrictions:
All arrays should have the same shape.

next up previous contents
Next: gprintf Up: APrintf Previous: APrintf   Contents
Bryan Carpenter 2004-06-09