THEOS Software (GB)
We are the UK distributor for THEOS Corona Operating System and companion products, including the THEOS BASIC programming language and THEO+Net network server software.
Advanced printing with THEOS Gutenberg
Many THEOS resellers use Gutenberg simply as a method to share printers between THEOS and Windows applications on the same network, or to provide a connection to multiple branch printers over the Internet. Although the product is very good at this, the advanced printing capability is much more interesting.
Traditional THEOS programs provide printed output by simply sending data, line by line, to a printer. Some developers extend this by supporting extra features of certain printers, but this often leads to hard-coding their programs for specific printers, which poses problems when the hardware becomes obsolete.
THEOS Gutenberg provides an API which gives the developer full control over the fonts, colours, sizes and position of the text that they need to output. It also supports line and box drawing, shading, and the placement of images on the paper. Using the Gutenberg API, the developer can have full control of the printed output, and provide modern-looking output, all from THEOS MultiUser BASIC.
The Gutenberg API is based on areas - the developer creates a print area, and assigns a range of properties to that area, including font name, size and style, alignment, foreground and background colours, and so on. When the area is selected, text sent to that area is given those properties when it is output.
Using this method, it is simple to lay out reports such as invoices and statements - simply define an area for each box of the report, set the properties, and print. One of the nice things about the area definition is that the position and size can be specified in millimeters, making it very easy to get the line-up exactly right.
The output is sent to the Gutenberg Server program which is running on a Windows PC. This then sends the output to the selected printer, formatting as required on the way.
Sample Code
The following short BASIC program will print a text string and an image via the Gutenberg server, note that the printer must be configured to be controlled by Windows.
10 INCLUDE "gutenb" - add the API calls into the language
20 OPEN #1: "PRT" OUTPUT SEQUENTIAL - open the printer channel
30 CALL BTPAREA(ADDROF(#1),1,1,20,30,100,50,4) - create an area, 20mm in, 30mm down, 100mm wide, 50mm high
40 CALL BTPSELECTAREA(ADDROF(#1),1,0) - select as the current area
50 CALL BTPFNAME(ADDROF(#1),"Arial") - assign a font
60 CALL BTPFSIZE(ADDROF(#1),120) - assign a size, in tenths of a point
70 CALL BTPFALIGN(ADDROF(#1),BTFA.LEFT%) - set left justified
80 PRINT #1:"Test Text Output"
90 CALL BTPAREA(ADDROF(#1),1,2,20,100,200,200,4) - create a second area
100 CALL BTPSELECTAREA(ADDROF(#1),1,0) - select as current area
110 CALL BTPIMAGE(ADDROF(#1),"picture.jpg",BTPF.JPG%) - assign image filename and type
120 CLOSE #1 - close the channel
130 END
Of course, in production code you would have a function or subprogram to create areas instead of repeating code, also you would check the return code from each of the API calls in case of problems. But the overall principle is that it is quite simple to produce modern-looking, device-independent printed output using the THEOS Gutenberg API.