Author Topic: S_PRINT, E_PRINT  (Read 3979 times)

0 Members and 1 Guest are viewing this topic.

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
S_PRINT, E_PRINT
« on: December 29, 2021, 01:16:01 pm »
I know from reading past threads that messing with the PRINT statement can be very dicey but if there is ever a consideration to expand on LPRINT I think it would be useful to have a way to sending large sections of your code to the printer. At the present time, to send a section of my code to the printer, I highlight the section and copy/paste it back with new lines in the program I'm coding. Then change the beginning of each line with LPRINT. In this way I get a hard copy of the code on the screen. But where the screen can only show me so many lines the hard copy provides lines of code not displayed. It is a pain in the butt to do all the highlighting, copy/paste and rewording the beginning of each line with LPRINT. Maybe you guys or girls have a better way to send a large section of code to the printer???

Anyway, the thought occurred to me while debugging, it may be helpful to have something like a command "S_PRINT" that you would place at the start of the lines to print and "E_PRINT" where you want the printing to End. I wonder if that approach might be easier than trying to add a Print option to highlighted sections of code??

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: S_PRINT, E_PRINT
« Reply #1 on: December 29, 2021, 04:44:06 pm »
Hi.
 Try _PRINTIMAGE.

Simply use the graphic commands to first paint the entire form on the monitor the way you want it to be printed (including fonts and rectangular input fields, including background images) and then send the result to the printer with this command. Don't forget to set a white background :)

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: S_PRINT, E_PRINT
« Reply #2 on: December 29, 2021, 05:03:14 pm »
@Dimster

For printing your source codes in printer try this program:

Code: QB64: [Select]
  1. Print "Source code printer. Input BAS source file name, start and end row to print at printer [" + Chr$(34) + "example.bas" + Chr$(34) + ", 50, 300]"
  2. Input Source$, Start, EEnd
  3. Dim PrintRows(EEnd - Start) As String
  4.     f = FreeFile
  5.     Open Source$ For Input As #f
  6.     While Not EOF(f)
  7.         Line Input #f, text$
  8.         row = row + 1
  9.         If row >= Start And row <= EEnd Then
  10.             PrintRows(i) = text$
  11.             i = i + 1
  12.             Print text$
  13.         End If
  14.     Wend
  15.     Print "Source code: "; Source$; " not found.": End
  16. Print "Source file reading done, printig rows from "; Start; " to"; EEnd
  17.  
  18. For Pr = 0 To UBound(PrintRows)
  19.     LPrint PrintRows(Pr)
  20.  

in begin insert inputs in format:

Example.bas,50,330         

It is source file name, start row, end row. Works fine for me.
« Last Edit: December 29, 2021, 05:13:15 pm by Petr »

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: S_PRINT, E_PRINT
« Reply #3 on: December 30, 2021, 09:32:18 am »
@Petr - Just rolled out of bed and found your code. Thanks for same. Going to get a coffee and play with it today. Keeping in mind I'm still not completely awake, is there a way to use a command similar to _Debug, where you insert the command and it automatically would attach your code to the program I'm writing??

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: S_PRINT, E_PRINT
« Reply #4 on: December 30, 2021, 09:43:25 am »
@Dimster
Hi, yes. For easy use, rewrite it as SUB:

Code: QB64: [Select]
  1. SLPRINT "Untitled.bas", 1, 28 'print this source code
  2.  
  3. Sub SLPRINT (Source$, Start, EEnd)
  4.     '    Print "Source code printer. Input BAS source file name, start and end row to print at printer [" + Chr$(34) + "example.bas" + Chr$(34) + ", 50, 300]"
  5.     '    Input Source$, Start, EEnd
  6.     Dim PrintRows(EEnd - Start) As String
  7.     If _FileExists(Source$) Then
  8.         f = FreeFile
  9.         Open Source$ For Input As #f
  10.         While Not EOF(f)
  11.             Line Input #f, text$
  12.             row = row + 1
  13.             If row >= Start And row <= EEnd Then
  14.                 PrintRows(i) = text$
  15.                 i = i + 1
  16.                 Print text$
  17.             End If
  18.         Wend
  19.    Close #f
  20.   Else
  21.         Print "Source code: "; Source$; " not found.": End
  22.     End If
  23.     '    Print "Source file reading done, printig rows from "; Start; " to"; EEnd
  24.  
  25.     For Pr = 0 To UBound(PrintRows)
  26.         LPrint PrintRows(Pr)
  27.     Next
  28.  

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: S_PRINT, E_PRINT
« Reply #5 on: December 30, 2021, 11:35:09 am »
Of course - thank you.