next up previous contents index
Next: Customized I/O Routines Up: Input and Output Previous: Read and Write

Control Strings

   

The format of each expression may be controlled using a control string that precedes the expression and is separated by a colon (:). These control strings use the same structure as the control strings in C printf() routines. For example, the following specifies that each element of the parallel array A will be printed to 5 decimal places.

    [north of R]  write("The north boundary contains ", "%.5f": A);
Note that the control string applies to each element of the parallel array. Thus, the following statement differs from the above in that the following will print "The north boundary contains" once for each element in [north of R], whereas the above statement will print the string just once.

    [north of R]  write("The north boundary contains %.5f": A);
Control strings also may be applied to sequential expressions. The colons are used strictly to separate control strings from expressions, so each colon must follow a string and precede an expression.



Kay Nettle
Fri Feb 21 21:14:29 CST 1997