How to print programs with line numbers?

Started by twgonder, July 08, 2021, 11:40:21

Previous topic - Next topic

twgonder

I'm working on a curriculum to teach BASIC to students in Spanish.
To do that, I will need to print the lessons which will themselves be written into the programs.

I need to print each entire program with the line numbers, for quick reference,
I've tried several ways, but the solution eludes me.
Any suggestions?

How about an option to print the programs from within the IDE?

Midimaster

An easy solution would be to write a short BASIC programm, that reads a code source files line by line and adds a number before it.

Also easy: Open the source file in a simple external text editor, which is able to print line numbers. I use the free text editor EditPad light: http://www.editpadlite.com on windows
...back from Egypt

twgonder

Quote from: Midimaster on July 08, 2021, 12:18:41
An easy solution would be to write a short BASIC programm, that reads a code source files line by line and adds a number before it.

Also easy: Open the source file in a simple external text editor, which is able to print line numbers. I use the free text editor EditPad light: http://www.editpadlite.com on windows

Both good ideas, except I would probably spend hours figuring out how to get a smallBASIC program to print to a windows printer.

The second option is a good solution for the short-term.

It would be really nice if the edit screen could print with all the nice colors used for the commands.

bplus

A little sb file to add line numbers and make a txt file to load in your favorite txt editor for printing:

fin = "basic proggie.bas" ' file to print
fout = "basic proggie.txt" ' txt file to print from fav WP
tload fin , f
i = 1
open fout for output as #1
for j = lbound(f) to ubound(f)
  print #1, right (space(5)+i, 5)+" " + f(j)
  i = i + 1
next
1 person likes this

Midimaster

Not a fast solution:

to add a functionality of colored printing with free selection of fonts and adding images too you need to add a library like CAIRO. With this you also can select "print to printer" or "print to PDF". In BlitzMax you could add Cairo-Support as a module into your app.
...back from Egypt