Cookie Consent by


VirtualAcorn Technical support:
Printing directly from BASIC programs

Quite often we are asked if VirtualAcorn products can print from BASIC. The answer, of course, is yes, with a proviso. The proviso being that the BASIC application concerned is using the RISC OS printing system. This allows any application running in the desktop to print to the same printer using the same printer definition files. The system is often referred to as !Printers.

As far as a RISC OS application is concerned, !Printers behaves the same regardless of the make/model of printer or the version of RISC OS in use. This is all well and good, but from experience we know that when a customer asks if they can print from BASIC they don't mean 'print' using !Printers, they mean 'print' in the same way that a BASIC program running on a BBC Model B would print to a dot matrix printer. This method is known as 'plain text' printing. The ASCII characters of the text being printed are sent to the printer. The printer itself then sorts out the font, formatting, paper sizes etc.

For some time our answer to this has always been sorry, no you can't. In the past we have suggested that the best idea is to re-write the program so it either works in the desktop, or saves a file out that can subsequently be printed by another application.

For various reasons a full re-write of the BASIC program may not be possible. I do however point out that whilst 'plain text' printing was great on dot matrix printers the world has moved on and that very few modern printers support 'plain text' printing. Or at least that's what we thought and sometimes it nice to be wrong.

We were contacted by Stuart Tyrell (of STD and Advantage Six fame) who had run into the same problem, but had sat down and come up with a solution. The solution, like all good ideas was very simple, worked perfectly and yet seemed totally bonkers. Stuart provide me with a sample piece of code as follows:

   10 : REM Printer Test 2 for VirtualAcorn
   20 : REM Stuart Tyrrell
   30 : REM
   40 : REM Set printer type 50 to point to the printer
   50 : REM To check the printer name:
   60 : REM a) Install the printer under Windows
   70 : REM b) Run "showprinters" in the printing directory in RISC OS
   80 : REM c) Replace the bit after HostFS:: with the printer name
   90 : *SET PrinterType$50 HostFS::Panasonic_KX_P7110_PCL6
  100 : :
  110 : REM Now select this printer type
  120 : *FX 5,50
  130 : :
  140 : REM Turn off the printer ignore character, otherwise everything
  150 : REM appears on one line!
  160 : *fx 182,255,0
  170 : :
  180 : REM Print something!
  190 : VDU 2
  200 : FOR T=1 TO 10
  210 : PRINT SPC(T*4);"test!!!"
  220 : NEXT
  230 : :
  240 : REM Don't forget the page feed, especially on a laser!
  260 : VDU 12
  261 : :
  262 : REM Bye!
  270 : VDU 3

As you can see the program sets up a printer type of 50, and then opens this printer, prints some text, then closes the printer. What had me stumped was that I couldn't see how it was working, especially as Windows itself can't do this trick! Eventually I realised what was happening. When VirtualAcorn prints it dumps data directly into the Windows print queue, by-passing most of the Windows printing system. The file that is generated by RISC OS simply gets sent straight to the printer with no further processing. So provided the printer "knows" what to do with plain text, it will print it.

Of course most printers sold these days are so called GDI printers, meaning they have no 'God Damn Intelligence', and shouldn't be able to print 'plain text'. However in testing we've found that a surprising number of modern printers seen to be able to cope. We don't have the resources to test every printer, so we cannot guarantee that this process will work with a particular make or model of printer, but it's worth trying if you need to print from BASIC. Worst case you will just have to turn the printer off and flush the Windows print queue.

It's a very trivial task to alter any single tasking BASIC program that prints out text to work using the above method and we thank Stuart for his creative solution.

[Home] [Products] [FAQ] [Order] [Contact] [Press Releases] [Tech Support] [Downloads]

 Copyright (c) 2021 3QD Developments Ltd. All rights reserved. All trademarks are acknowledged. All details are correct at the time of publication, E & OE.
Last Edit Date 31/03/21