Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Print source code from the IDE
#1
I haven't printed anything since the beginning of the year, didn't have to since everything was done via email, but now I wanted to print some source code, but how? See the screenshot. How should I print this source code? I could copy it to Notepad++. . .

If I didn't miss anything, then that is a serious mistake.

[Image: Quelltext-drucken.jpg]

bild server
Reply
#2
FROM:

https://qb64phoenix.com/qb64wiki/index.php/SHELL

(Example #2):

Code: (Select All)
INPUT "Enter a file name to read in Notepad: ", filename$
SHELL "CMD /C start /max notepad " + filename$  ' display in Notepad full screen in XP or NT  

'SHELL "start /min notepad /p " + filename$ ' taskbar print using QB64 CMD /C not necessary

Maybe you would like to fix it up so it always looks for a file inside QB64 folder or wherever else you save your source code.
Reply
#3
I'm not sure how many lines of code you have to send to the printer but if it's not that many I simply use the LPRINT statement. Using the Find Replace, I first change all Print to LPrint and then all the other lines of code which do not have a Print statement I just insert LPRINT " at the beginning of the line. After printing I put the code back to it's original. The more code you want to print the more tedious this is but it works.

IE Original Code

A = 5
B = 33.3
C = 123

If B > C then exit sub
if C > B then 
    F = A * B
    Print F
End If


Using SEARCH - FIND - REPLACE
  Find Print
  Replace with LPrint

Using Copy Paste - Insert LPrint " at the beginning of each line. 

Code to  printer now looks like this

LPrint "A = 5"
LPrint "B = 33.3"
LPrint "C = 123"

LPrint "If B > C then exit sub"
LPrint "if C > B then "
    LPrint "F = A * B"
    LPrint F
LPrint "End I"


It would be nice if there was a print to printer option in the IDE tools but I understand PRINT is a monster on it's own to deal with. Not sure if this helps you at all.
Reply
#4
I use to save hardcopies of code back in 90's glad to be out of habit. 

Though sometimes you can see things when printed out that you might miss from inside IDE.
But scanning code in IDE is way faster and less wasteful of paper and ink.
b = b + ...
Reply
#5
Thanks for the tips. Looks everything tremendous.
I print out source code if it's interesting because I then make notes about it. And I also print out various instructions. Under Vista Ultimate I once ruined the system with a partitioning tool. That was bad because my private data was encrypted. It took me 13 hours to salvage the system and I couldn't have done it without guidance.

Well, copying and pasting the text into Notepad++ is probably more practical. Maybe someday there will be a print function in the IDE. They must have forgotten that, because there was a print function in QuickBasic 4.x.

[Image: Druck-mit-Quick-Basic4.jpg]
Reply
#6
Yeah when if I need something printed I used a WP but I have gotten great results with _PrintImage. Just convert what you want printed into images. I've had great success with calendars, accounting forms and shopping lists. OK might be a little work with lines and lines of text, make a little convert app to take a bas file, divide it to pages and print blocks of text to image using _PrintImage? Depends how much stuff you have/want to do.
b = b + ...
Reply
#7
(11-27-2022, 04:48 PM)Kernelpanic Wrote: Well, copying and pasting the text into Notepad++ is probably more practical. Maybe someday there will be a print function in the IDE. They must have forgotten that, because there was a print function in QuickBasic 4.x.
Not as much that it was forgotten. Life was a lot simpler while QuickBASIC was king -- a lot, as far as printers were concerned. There was no such thing as USB. It was before manufacturers made things more difficult than they needed to be and people demanded out of line-printer and dot-matrix territory into laser-printer high quality. If we still had to deal in the majority with dot-matrix printers then QB64(PE) would have had a print function in its IDE a long time ago.

Galleon and his supporters were still cool enough to come up with a graphics printing job that could be appreciated.

Dimster made a point which could be developed further into a program that reads source code and just uses "LPRINT" to print each line, careful to decorate the pesky CHR$(34).
Reply
#8
Visual Studio Code doesn't print from the IDE either. If the programmer wants to print source code, the process it to download a plugin that exports the source to HTML and then opens a browser on it. From there the programmer can print.

So we could do the same in QB64 IDE: export to HTML and then shell to browser

-- Bruce
Reply
#9
Welcome to the forums.

I wish there was another program, which is not a &%$*#@ing web browser that could display HTML documents formatted properly. It's because no web browser loads fast, and tolerable enough to use it offline like the first few versions of Internet Explorer and Firefox.

This way could work for documents greater than 1MB. But source code seldom gets that big, definitely not C++ or Python or any other OOP. I proposed advice that was given away for free for many years in the QB64 Wiki, which doesn't apply to those on Unix-like operating systems that cannot have Wine.

Hmmm... doesn't Visual Studio IDE have an option to run a program EXE file with command-line arguments? Then QB64(PE) could be used to write a program that does the printing, after it's passed an ordinary text file. Just use "LPRINT" and watch out for CHR$(34) put literally in the code.

EDIT: It requires the code to be saved as ordinary text file. Now I don't remember but I read somewhere that things could get as perverse as binary signatures and stuff like that being part of a function header! Don't want to anger somebody about what it looks like his/her favorite tool...
Reply
#10
(12-10-2022, 07:47 AM)mnrvovrfc Wrote: Welcome to the forums.
Thanks for the welcome.

Another option is to pick some other page description language (Markdown, LaTEX, PostScript), shell to a renderer and print from there.

I get it that none of these options are as nice as LPRINT. I was thinking more about printing out source than actually allowing QB64PE to open a print job (using say Desktop App Printing) and directing text and metadata to it. Some way-better-than-me Win32 programmer might want to do that some time.

-- Bruce
Reply




Users browsing this thread: 1 Guest(s)