PRINT

Print is used to output constant text and variable data to either the screen or a file, depending upon the current status of the keyword OUTPUT.

Syntax:

PRINT 
PRINT X
PRINT "The value of x is ", x
PRINT " x = ", x, " x + y = ", x + y
 

Discussion:

PRINT alone will print a blank line. PRINT with a list of text arguments and expressions will print each text string (enclosed in double quotes) and the numeric value of each expression. PRINT uses the numerical output format specified by FORMAT. If the last item in the list is followed by a comma, PRINT will not end the line with a carriage return.

Note that very large quantities of PRINT commands (i.e. thousands of lines or more) can negatively impact macro execution speed if the printed text is displayed on the screen (i.e. OUTPUT SCREEN).

The reason this can cause slowdown is because OpticStudio handles these print windows as a single string. As the string gets longer and longer (as you print more lines of data out to the window), it becomes more computationally costly to display it and store it. In other words, the problem is that the PRINT overhead linearly increases with each loop iteration.

So to retrieve a lot of textual data from a macro:

  • The best solution is to use PRINT to save to a file instead of pushing to the window (i.e. use OUTPUT filename). It will make the macro more efficient, by avoiding the inefficiencies of printing to the ZPL output window.
  • To display the results on the screen, consider using a "child" macro. The "child" macro will only print one string at a time.OUTPUT SCREENa$ = "This text gets really really long."CALLSETSTR 1, a$CALLMACRO PRINT.ZPLThe macro PRINT.ZPL will only display a$:A$ = $CALLSTR(1)PRINT A$

Example:

X = 3
PRINT "X equals ",x
 

Related Keywords:

REWIND

Next: