pcf - Print Control Forms Compiler and Program Interpreter (PI).



Synopsis
pcf [options] [file]
Description
pcf is a general purpose program interpreter which uses a similar syntax as "C". It can operate interactively, or as a pipe process reading command statements from standard input. Or it can operate as a program interpreter on a program defined in a named file.
Interactive usage
When pcf is called from a terminal session without any arguments, it will operate as an interactive shell. A "pcf>" prompt will be output when it is ready to read a statement from standard input. If the statement is incomplete, or it spans across multiple lines, a secondary ">" prompt will be output indicating that further input is required, as in the following example;
$ pcf
pcf> y = 3;
pcf> for (x=0; x<y; x++) {
> write(stdout,x);
0
> }
1
2
pcf>

The statements typed during the terminal session is shown in bold type, while the prompts are shown in red. In the above example, the secondary prompt is displayed after the compound statement following the "for" loop is entered. The first result of the "write" function is output immediately, and the subsequent results are output immediately after the compound statement is completed with the closing brace. The interpreter then displays the primary prompt.

If an expresion is preceded by a question mark, the result of the expression will be printed on the following line, as shown in the following example;
$ pcf
pcf> x = 4;
pcf> y = 3;
pcf> ? x += y;
7
pcf>
return;
$


The interactive session is terminated by typing "return;" or the EOF character (control D).
Forms compilation
pcf can operate in a Unix command pipe line. It is normally called in this fashion to compile Print Control forms. Program statements are read from standard input and the compiled form is written to standard output. In this situation, pcf would normally be called with the "-T" option to invoke the appropriate printer driver, e.g.;
$ cd $Utools/Utools
$ bin/pcf -TPDF < macros/source/pcf_example1 > /tmp/out.pdf
Program Interpreter
As a full function program interpreter, pcf will execute a set of subroutines which are defined within the glossary file named on the command line as file. By default, program entry will commence in the "main" routine, unless a "-s" option is given. In the following example, the named glossary file contains only the default entry subroutine called "main";
cat /tmp/hello
#main
fputs("Hello World!\n",stdout);
))
pcf /tmp/hello
Hello World!
$

Options
-i file
Standard input will be redirected from the named file
-o file
Standard output will be redirected to the named file
-E file
Standard error will be redirected to the named file
-s subroutine
Call the named subroutine instead of the default entry routine "main()"
-m macro
Compile and generate a PCL macro with number macro
-T mode
Open output driver library file mode. e.g. -TPCL will open the output driver $Utools/Utools/include/PCL.pi. and the entry and exit functions, PCL_mode_begin() and PCL_mode_end() will be called.
-R
Report writer mode. Do not call the entry and exit functions for the given output mode.
-v var=val
Predefine global variable var with the value of constant val.
-D flag
Enable debugging level. See table below for bit values for flag.
Debug Flags
The debug value supplied to the "-D" command line option is a bit mask which may be composed from the sum of the following values. For example, to turn on statement and expression debugging, supply option "-D5" on the command line.
Value
Facility
1
Statements
2
Compund Statements
4
Expressions
8
Constants
16
Functions
32
Variables
-1
All of the above

Global Variables
The following variables are declared with global scope by pcf;
Name
Type
Purpose
stdin stdout stderr
IS_FILE
Standard input, output and error file streams.
thous_char radix_char
IS_INTEGER
Number formatting characters.
Text_Length
IS_FLOAT
Length of last text string (in mm).
max_X max_Y
IS_FLOAT
Maximum extent of last element placed on the page.
Page_End
IS_FLOAT
Used  by PCR to determine  pagination

See Also
Detail description of PI syntax is available in the following documents;
Detailed synopsii of the inbuilt functions are described in the following documents;