Hello world


Like almost any programming book, we must start by printing the famous "Hello world" using PageScript 32. Every example assumes that PSInit() returns zero (no error).

Example - [x]Harbour, using functions, procedures and commands wrappers

1 #Include "PScript.ch"
2 if PSInit() == 0
3    BEGINDOC USING 0 TITLE "Hello world"
4       PSSetUnit(APS_TEXT)
5       PSSetLPI(6)
6       PSSetCPI(10)
7       @5,5 TEXTOUT "Hello world"
8    ENDDOC
9 endif

Lets explain the code, line by line.

Line 1 is the standard Include statement. PSCRIPT.CH contains all deinitions you need to work with PageScript 32.

Line 2 initializes PageScript 32. If everything is OK, it returns 0.

Line 3 starts a new print job, on the default printer with the title set to "Hello world"

Line 4 sets the unit of mesurement to text coordinates that barely mimics old DOS printer's rows and columns coordinate system.

Line 5 sets the number of LPI (lines per inch) to 6. The default value is 6, so this line is not required. We added it for demonstration purposes only.

Line 6 sets the number of CPI (characters per inch) to 10. The default value is 10, so this line is not required. We added it for demonstration purposes only.

Line 7 send the command to print "Hello world" at column 5 and row 5. It uses the default/current set font, font size, font foreground and background colors.

Line 8 ends the print job.

Line 9 is the end of the if structure.


PageScript 32 is shipped with a demo program (PSTEST.EXE) for [x]harbour (althgough every 32 bits programming languages are supported) that demonstrates most of the aspects and techniques to produce all kind of documents. We invite you to open and study these sample programs.