Ooops
September 28, 2021, 05:22:51

Author Topic: How to print programs with line numbers?  (Read 375 times)

Offline twgonder

  • Jr. Member
  • **
  • Posts: 29
How to print programs with line numbers?
« on: July 08, 2021, 11:40:21 »
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?

Offline Midimaster

  • Sr. Member
  • ****
  • Posts: 363
    • Midimaster Music Education Software
Re: How to print programs with line numbers?
« Reply #1 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
See my current project on PlayStore: 20Tracks-Audio-Player https://play.google.com/store/apps/details?id=midimaster.twentytrackd

Offline twgonder

  • Jr. Member
  • **
  • Posts: 29
Re: How to print programs with line numbers?
« Reply #2 on: July 08, 2021, 13:01:23 »
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.

Offline bplus

  • Full Member
  • ***
  • Posts: 221
Re: How to print programs with line numbers?
« Reply #3 on: July 08, 2021, 21:38:04 »
A little sb file to add line numbers and make a txt file to load in your favorite txt editor for printing:
Code: [Select]
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

Offline Midimaster

  • Sr. Member
  • ****
  • Posts: 363
    • Midimaster Music Education Software
Re: How to print programs with line numbers?
« Reply #4 on: July 09, 2021, 07:35:29 »
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.
See my current project on PlayStore: 20Tracks-Audio-Player https://play.google.com/store/apps/details?id=midimaster.twentytrackd

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal