Example of a Procedure defined in PALTM
The following procedure is defined in Pal_Procs_and_Formats.txt and illustrates how PALTM commands may be combined in a procedure to create a completely new function or capability. The file Pal_Procs_and_Formats.txt must be copied to the printer prior to using any of these utilities. The following utility shows how PALTM operators are used to create a simple Box draw procedure. This Box procedure makes use of another procedure defined called inchtopts. This procedure takes measurements in inches and converts to points which is the native unit used by PALTM. The advantage of using a procedure like this to draw boxes is to simplify the use of the PALTM language. Instead of issuing 7 PALTM commands to draw a box, this single procedure may be called with 5 parameters (lower left corner x,y, upper right corner x,y, and line width).
%========================================================================
% Box draw procedure |
|
|
|
|
| |
% Usage: | botX(in.) | botY(in.) | topX(in.) | topY(in.) | lwidth(in.) | Box |
% Example: | 0.1 | 0.1 | 3.9 | 1.9 | 0.01 | Box |
% |
|
|
|
|
|
|
% | (topX, topY) |
|
|
|
|
%
% | ||
% |
%
%(botX, botY)
%
%========================================================================
/Box
{
/lwidth exch def /topY exch def /topX exch def /botY exch def /botX exch def
botX inchtopts botY inchtopts moveto botX inchtopts topY inchtopts lineto topX inchtopts topY inchtopts lineto topX inchtopts botY inchtopts lineto closepath
lwidth inchtopts setlinewidth stroke
} bind def
Example of calling a Procedure from a host application
The two lines preceded by % are comment lines ignored by the PALTM interpreter and don't actually need to be transmitted to the printer. The last line shows the actual call to the procedure named Box defined in Pal_Procs_and_Formats.txt. Note that floating point numbers must have a leading 0 for example 0.1 instead of .1. Also note while the example below uses many spaces between parameters, this is only for clarity and only a single whitespace character is actually needed i.e. 0.1 0.1 3.9 1.9 0.01 Box would also work.
%Box draw
%botX(in.) botY(in.) topX(in.) topY(in.) lwidth(in.) Box
0.1 | 0.1 | 3.9 | 1.9 | 0.01 | Box |
Fastmark 600 Series User's Guide | 54 |