Copyright 2008 Shoptalk Systems

PRINT expr[;]
PRINT #handle, expr[;]


The PRINT statement is used to display information on the web page.  This is different from the HTML statement in that it escapes characters that would otherwise cause markup tags to be formed. 

So, using an HTML statement like so:

  html "<b>This is bold</b>"

Produces this on the web page:

This is bold

But using a PRINT statement like so:

  print "<b>This is not bold</b>"

Produces this on the web page:

<b>This is not bold</b>

Using a semicolon to prevent a line break

By default the PRINT statement will force a line break.  The following code will display two lines of text:

  print "The quick brown fox"
  print "jumped over the lazy dog"

But by adding a semicolon to the end of the first line it display only one line of text.

Using a semicolon to mix output together

The semicolon is also useful for displaying mixed data on a line.  For example:

  a = 3
  b = 4
  c = sqr(a^2+b^2)
  print "The hypotenuse of a right triangle with two sides of length "; a; " and "; b; " is "; c

Printing to a file

When printing to a file we use the form PRINT #handle, expr.  The file being printed to must be in the variable named #handle.  The optional semicolon is permitted in this form of PRINT as shown below.


  open "example.txt" for output as #writeHere
  print #writeHere, "The time has come for all good men ";
  print #writeHere, "to rise to the aid of their country."
  close #writeHere