Google

Yorick Reference Card

yorick banner

Home

Manual

Packages

Global Index

Keywords

Quick Reference

Yorick Language Reference

Writing Text

write, f, expr1, expr2, .., exprN writes the exprI to file f
write, expr1, expr2, .., exprN writes the exprI to terminal
swrite(expr1, expr2, .., exprN) returns the exprI as a string

The swrite function returns an array of strings - one string for each line that would have been produced by the write function.

The exprI may be arrays, provided the arrays are conformable. In this case, the exprI are broadcast to the same length L, then the write is applied as if called L times, with successive elements of the exprI written on each call.

Both functions accept an optional format keyword. Write format strings in Yorick have (nearly) the same meaning as the format strings for the ANSI stacndard C library printf routine. In brief, a format string consists of:

  • characters other than %
    which are copied directly to output
  • conversion specifiers beginning with %
    of the general format %FW.PSC where:
    • F is zero or more of the optional flags - (left justify), + (always print sign), (space) (leave space if +), 0 (leading zeroes)
    • W is an optional decimal integer specifying the minimum number of characters to output
    • .P is an optional decimal integer specifying the number of digits of precision
    • S is one of h, l, or L, ignored by Yorick
    • C is d or i (decimal integer), o (octal integer), x (hex integer), f (fixed point real), e (scientific real), g (fixed or scientific real), s (string), c (ASCII character), or % (the % character - not a conversion)

For example,
> write, format="   tp %7.4f %e\n", [1.,2.], [.5,.6]
   tp  1.0000 5.000000e-01
   tp  2.0000 6.000000e-01
>