next up previous contents index
Next: Conditionals Up: Statements Previous: Empty Statement


    The print statement provides a simple way of displaying (to Glish's stdout) values. Its syntax is:

print valuetex2html_wrap_inline15496, valuetex2html_wrap_inline15498, tex2html_wrap_inline15512
where any number of values may be listed (including none, which produces a blank line).

  By default, large amounts of output are sent through a pager, e.g. less or more. This prevents the information from being overwhelming. The pager to be run is determined by system.output.pager.exec and the line limit where paging starts is determined by system.output.pager.limit. Setting the limit to 0 will cause the pager to always be used, and setting it to -1 will cause it to never be used.

At the moment printing of values is crude. Values are printed with a single blank between them and a final newline added at the end.     There only two ways of affecting the printing of Glish values. These can be either be used as an attribute to a given value or specified for the whole system.

Print Precision

      The first is print.precision. Sometimes it is important to increase the amount of decimal precision used to print floating point values. This sets the number of significant digits which are used to display floating point numbers. If this is set in the system record, then the default output behavior is changed for the entire system:

    a := 142.8767901343
    print a
    system.print.precision := 10
    print a
In this example, the precision is set to 7. The output would look something like:
Note that this sets the number of significant digits not the number of decimal places The print precision can also be set for individual values by setting attributes of the value. In this case, it only affects how this single value is printed. Continuing the example above:
    Pi := 3.141592653589793238462643
    print Pi
    Pi::print.precision := 15
    print Pi
    print a
The output this time would look like:
This provides a very basic way of controlling the output precision of floating point numbers. Setting precision to a negative integer resets the default printing behavior for both system and attribute.

Print Limit

      The second is print.limit. This is used to avoid inadvertently printing very large values to the screen. This again can be specified as part of the system record to change the default print limit for the system, or it can be specified as an attribute of any value. So for example:

    a := 1:1e7
    # print a              # this would be a mistake!
    a::print.limit := 10
    print a
By setting the print limit for a we would get this output:
    [1 2 3 4 5 6 7 8 9 10 ... ]
instead of many pages of integers. As with print.precision this can also be set in system to change the limit for the whole system. Setting limit to be 0 or a negative integer resets things to the default limit, i.e. no print limit.    

  In the future print must be extended to allow more sophisticated formatting.  

next up previous contents index
Next: Conditionals Up: Statements Previous: Empty Statement

Thu Nov 13 16:44:05 EST 1997