Printing SuperBASIC programs

Anything QL Software or Programming Related.
EmmBee
Trump Card
Posts: 240
Joined: Fri Jan 13, 2012 5:29 pm
Location: Kent

Printing SuperBASIC programs

Post by EmmBee »

Does anyone know of any software capable of printing out a SuperBASIC program?

I use ED from toolkit 2 to construct my programs, but they don't print out as displayed on the QL screen. Using windows software I always have to spend time formatting the text, and even then make mistakes.

Michael
EmmBee


User avatar
polka
Trump Card
Posts: 196
Joined: Mon Mar 07, 2011 11:43 am

Re: Printing SuperBASIC programs

Post by polka »

You should use evenly-spaced fonts like "Courrier New", then there would be no formatting issues.

Paul (or I don't understand your problem ?)


May the FORTH be with you !
POLKa
User avatar
Mr_Navigator
QL Fanatic
Posts: 782
Joined: Mon Dec 13, 2010 11:17 pm
Location: UK, Essex
Contact:

Re: Printing SuperBASIC programs

Post by Mr_Navigator »

I assume you are using an emulator, if so save the SuperBASIC file to a DOS/WINDOWS folder as normal e.g. Myprogram_BAS.

Then in Windows open the file using Wordpad which comes installed on all versions of Windows, the file should display perfectly in Wordpad as it defaults to 'courier new' for basic text files which is how Wordpad see's the SuperBASIC program.

Select PRINT in the normal way

If you do not like the font in Wordpad, Select all, change font to something you do like

If you want a font that looks like what you see on the QL then you can down load from Dilwyn's site one that I made earlier based on the JS ROM character set here http://www.dilwyn.me.uk/fonts/index.html and look for Sinclair-style Font True Type/ATM/Proforma and the name ql_jsrom.zip (21KB) - True Type version.

Install on your system and then you can view and print all your listings in this font.


-----------------------------------------------------------------------------------
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/
RWAP
RWAP Master
Posts: 2837
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: Printing SuperBASIC programs

Post by RWAP »

The other option is to purchase and install QPCPrint - that can be used on Windows computers with any of the QL emulators (and even DOS programs).

It basically takes the QL output (text, and graphics, using EPSON codes) and then converts it so that it can be printed under Windows in basically the same layout as you would get on a standard QL to a fully ESC/P2 compatible Epson printer

An excellent program and what I always use for my printing from the QL.


EmmBee
Trump Card
Posts: 240
Joined: Fri Jan 13, 2012 5:29 pm
Location: Kent

Re: Printing SuperBASIC programs

Post by EmmBee »

I was concerned more about how a SuperBASIC program could be printed out, especially one that contains long lines. Using ED, the lines after the first one are indented four spaces in. On the QL screen there are a maximum of 85 characters to the line. I am using Q-emuLator, which has a virtual printer, but this can only print out 69 characters to the line – and that doesn't allow for margins. Also, how about word-wrap? I was just wondering whether anyone had already written something specifically for this purpose. There could be a program somewhere that asks you to enter the number of characters to line, and about various options about word-wrap, indenting of long lines etc. This program would then read your existing SuperBASIC code and produce a text file ready for printing out on your chosen printer. If no such program exists, it could be an idea for someone to write such a program. Do you think this could be popular?

Michael
EmmBee


User avatar
Mr_Navigator
QL Fanatic
Posts: 782
Joined: Mon Dec 13, 2010 11:17 pm
Location: UK, Essex
Contact:

Re: Printing SuperBASIC programs

Post by Mr_Navigator »

On the old ZX Spectrum you did this LLIST straight to a ZX printer or the American Alphacom printer on nice shiny grey metallic paper and I believe it did retain exactly what appeared on screen.

Not so simple on the QL though :(


-----------------------------------------------------------------------------------
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/
RWAP
RWAP Master
Posts: 2837
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: Printing SuperBASIC programs

Post by RWAP »

I am not quite sure I understand the issue....

I would just use:

OPEN #3,'par'
LIST #3
CLOSE #3


User avatar
Mr_Navigator
QL Fanatic
Posts: 782
Joined: Mon Dec 13, 2010 11:17 pm
Location: UK, Essex
Contact:

Re: Printing SuperBASIC programs

Post by Mr_Navigator »

See, told you not so simple, however you could do this

10000 DEFine PROCedure LLIST
10010 OPEN #3,'par'
10020 LIST #3
10030 CLOSE #3
10040 END DEFine


-----------------------------------------------------------------------------------
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/
User avatar
dilwyn
Mr QL
Posts: 2761
Joined: Wed Dec 01, 2010 10:39 pm

Re: Printing SuperBASIC programs

Post by dilwyn »

RWAP wrote:I am not quite sure I understand the issue....
I would just use:
OPEN #3,'par'
LIST #3
CLOSE #3
...or even SAVE PAR which is functionally similar thanks to QL device independence both saving and listing BASIC progs as plain text.

But I suspect a misunderstanding as the requirement was not well explained.

I think what is meant is not just inability to list, but a requirement to format listings formatted more like the TK2 ED command, with indented lines. Below is a base program for doing this, which I will leave to all on this list to improve and adapt.

It's just a procedure called LLIST which will list a program with indented lines like Toolkit 2 (i.e. if line of BASIC is wider than the window, the second and subsequent parts of a line are indented by a few characters like Toolkit 2 (default 4 characters), and allows a left margin to be specified if required too (e.g. if the listing needs a margin to allow ring binder holes to be punched in the paper).

Alter the default settings in lines 30040 to 30080 (listing device, left margin, line width, indent and filename of a temporary file to use for the listing.

I've put in lots of REMs to explain how it works.

Possible improvements would include
  • a proper word wrap instead of just chopping (ED-style) at line width.
  • indenting (QL manual says lines within structures like loops and procs to be indented by two spaces)
Anyway, something for you to tinker with!

Dilwyn

100 REMark TK2-ED-style formatted listings, by Dilwyn Jones February 2012
110 :
120 LLIST 1 TO 32767
130 :
30000 DEFine PROCedure LLIST (first_line%, last_line%)
30010 LOCal device$,left_margin%,line_width%,indent%,temporary$
30020 LOCal get_line,lne$
30030 REMark default settings
30040 device$ = 'PAR' : REMark SER1/SER2/PAR/PRT etc
30050 left_margin% = 10 : REMark left margin (characters)
30060 line_width% = 60 : REMark line width (characters)
30070 indent% = 4 : REMark TK2-ED-style indent (characters)
30080 temporary$ = 'ram1_tmp_dat' : REMark temporary listing file
30090 :
30100 OPEN_NEW #3,device$ : REMark send formatted listing to here
30110 :
30120 REMark send a listing to work on to temporary$
30130 OPEN_NEW #4,temporary$ : LIST #4,first_line% TO last_line%
30140 CLOSE #4 : OPEN_IN #4,temporary$
30150 :
30160 REPeat get_line
30170 IF EOF(#4) THEN BPUT #3,12 : EXIT get_line : REMark form feed after last line
30180 INPUT #4,lne$ : REMark get line of BASIC into a string
30190 :
30200 REMark first section of line is not indented
30210 IF LEN(lne$) <= line_width% THEN
30220 REMark whole line of BASIC will fit on one line
30230 PRINT #3,FILL$(' ',left_margin%);lne$ : NEXT get_line
30240 ELSE
30250 REMark print first section without indent
30260 PRINT #3,FILL$(' ',left_margin%);lne$(1 TO line_width%)
30270 lne$ = lne$(line_width%+1 TO LEN(lne$))
30280 END IF
30290 :
30300 REPeat listing
30310 IF LEN(lne$) <= (line_width%-indent%) THEN
30320 REMark last section of line to list
30330 PRINT #3,FILL$(' ',left_margin%+indent%);lne$
30340 EXIT listing : REMark that was last section of this line
30350 ELSE
30360 REMark print current section of line
30370 t$ = lne$(1 TO line_width%-indent%)
30380 PRINT #3,FILL$(' ',left_margin%+indent%);t$
30390 IF LEN(lne$) > LEN(t$) THEN
30400 REMark truncate line to section not printed yet
30410 lne$ = lne$(LEN(t$)+1 TO LEN(lne$))
30420 ELSE
30430 lne$ = '' :REMark finished
30440 EXIT listing
30450 END IF
30460 END IF
30470 END REPeat listing
30480 END REPeat get_line
30490 :
30500 PRINT #3,CHR$(12); : REMark form feed last sheet of paper
30510 :
30520 CLOSE #4 : CLOSE #3 : DELETE temporary$
30530 :
30540 END DEFine LLIST


stevepoole
Super Gold Card
Posts: 714
Joined: Mon Nov 24, 2014 2:03 pm

Re: Printing SuperBASIC programs

Post by stevepoole »

I use the following procedure added at the end of my code :
To get a printed listing from any printer, just typre the command print_out after a break.
But note that when the listing has been printed, you need to turn off the printer manually!
I do this very often, and it has never failed in years.

1000 REM merge this listing onto your code.
1010 ::
1020 DEfine PROCedure print_out
1030 LOCal loop,i$,j$
1040 SAVE_O win1_programname_bas: PAUSE 500: REMark tweak this...
1050 OPEN#3,win1_programname_bas: OPEN#4,par: REM ditto
1060 REPeat loop
1070 INPUT#3,i$
1080 if EOF(#3): EXIT loop
1090 j$=i$&CHR$(13): PRINT#4,j$
1100 END REPeat loop
1110 PRINT#4,CHR$(12)
1120 ClOSE#4: CLOSE#3
1130 END DEFine
1120 ::


Post Reply