32 bit version 4.30
32 bit version 4.30
I downloaded this version and when I went to print my code I couldn't! How can I print my code? There is no icon for print on the Toolbar and none of the menu's even mention the word Print very Perplexing??
It took 73 years for me to get this Stupid!
-
- Enthusiast
- Posts: 203
- Joined: Sat May 23, 2009 4:39 am
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
I think Scintilla has a Print system - if so it should be fairly easy for it to be added to the editor. Maybe as a plugin?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
@Zooker:
Below is a 'Print Source Code' plugin for the standard PureBasic IDE.
I wrote it in 2006 but recently updated it for PureBasic 4.31. Please feel free to experiment with it.
You will need to compile it and then plug the .EXE file into the PureBasic IDE via this menupath:
Tools -> Configure Tools -> New
Set the Commandline to the full pathname of the compiled .EXE file.
Set Arguments to the exact contents of the next line:
"%SELECTION" "%TEMPFILE" "%FILE"
Leave the Working Directory field empty
Set Name to something like: Print Source Code
Set Event to trigger the tool to: Menu or Shortcut
Leave everything else empty.
Before running the plugin (from the bottom section of the IDE Tools menu), highlight the source lines to be printed on the default printer.
If 0 or 1 lines are highlighted, the entire source code will be printed.
If code folding is not working correctly, take the IDE menupath
File -> Preferences -> Editor -> Folding
Ensure ;- is on the list of Folding Start Keywords.
Ensure ;} is on the list of Folding End Keywords.
If the plugin fails to print anything, the probability is that a bug may exist in these lines of code:
Below is a 'Print Source Code' plugin for the standard PureBasic IDE.
I wrote it in 2006 but recently updated it for PureBasic 4.31. Please feel free to experiment with it.
You will need to compile it and then plug the .EXE file into the PureBasic IDE via this menupath:
Tools -> Configure Tools -> New
Set the Commandline to the full pathname of the compiled .EXE file.
Set Arguments to the exact contents of the next line:
"%SELECTION" "%TEMPFILE" "%FILE"
Leave the Working Directory field empty
Set Name to something like: Print Source Code
Set Event to trigger the tool to: Menu or Shortcut
Leave everything else empty.
Before running the plugin (from the bottom section of the IDE Tools menu), highlight the source lines to be printed on the default printer.
If 0 or 1 lines are highlighted, the entire source code will be printed.
Code: Select all
; PrintFile AKJ 23-Jul-09 PB Add-in Tool
; Print a text file whose path is given as a command line parameter
; Lines too wide for the page are wrapped onto subsequent print lines
; Page titles, page numbers & line numbers are printed (as suggested by yrret)
; Any PureBUILD build number is included in the title (as suggested by yrret)
; If multiple text lines are selected, only those lines are printed,
; except: if only one line is selected, the entire file is printed
; The add-in tool configuration arguments must be "%SELECTION" "%TEMPFILE" "%FILE"
; www.purebasic.fr/english/viewtopic.php?t=19876
EnableExplicit
;- Constants
#program$="PrintFile"
#version$="2.4"
#file=1
; The following constants may be edited by the user:
#gap=5 ; Vertical gap (leading) in pixels between print lines
#Lmargin=200 ; Left hand margin in pixels
#Rmargin=100 ; Right margin in pixels
#Tmargin=180 ; Top margin in pixels
#Bmargin=0 ; Bottom margin in pixels
#continue$="" ; Continuation character shown at the start of non-empty overflow lines
;}
;- Declarations
Global NewList lines$() ; Buffer for storing the print lines prior to printing
Define selection$ ; Limits of selected text
Define linefrst, linelast ; First/last selected text lines
Define path$="" ; Pathname of file to be printed
Define pagew, pageh ; Page dimensions in pixels sans margins
Define linenumw ; Width in pixels of the line number column
Define printw ; Width available for printing file text (excludes the line number column)
Define lineh ; Vertical distance in pixels between lines
Define lpp ; Lines per page available for printing (including title lines)
Define pages ; Number of pages that will physically be printed
Define pagenumx ; Start position of the right-aligned page number
Define title$="" ; Title (excluding page number) at the top of each page
Define titlew ; Width in pixels available for the title
Define ln$ ; The text line currently being processed/printed
Define tmp$ ; Temporary string variable
Define whitespace$ ; A copy of any whitespace at the start of the current line
Define cut; Position at which a text line must be cut to fit on the page
Define p ; Position within text strings and command line parameter number
Define overflow$ ; Flag: "#" (line has a line number) or "+" (continuation line)
Define build$="" ; PureBUILD build number
Define pagenum=0 ; Current page number
Define linenum=0 ; Current printed line number within source file
Define line=0 ; Lines printed on the current page
Define y=#Tmargin ; Vertical print position on the current page
;}
;- Identify text selection from the command line
selection$=ProgramParameter(0)
linefrst=Val(StringField(selection$, 1, "x"))
linelast=Val(StringField(selection$, 3, "x"))
; If the selection ends at the beginning of a line, treat it as ending on the previous line
If StringField(selection$, 4, "x")="1": linelast-1: EndIf
; If the selection is confined to one line, print the entire file
If linefrst>=linelast: linefrst=1: linelast=99999: EndIf
;}
;- Get file pathnames from the command line
; path$ will point to the latest in-memory version of the file
; title$ will contain the program's pathname if it has ever been saved
For p=1 To 2
tmp$ = ProgramParameter(p)
If FindString(LCase(tmp$), "\purebasic_tempfile", 1) ; If a temporary filename
path$=tmp$
ElseIf Len(tmp$)
title$=tmp$
EndIf
Next p
If path$="": End: EndIf ; Quit without error message
If FileSize(path$)<=0: : End: EndIf ; Quit without error message
;}
;- Initialise printer and get printer metrics
If DefaultPrinter()=0
MessageRequester(#program$+" Error", "Cannot open default printing device")
End
EndIf
StartPrinting("Text File")
pagew=PrinterPageWidth()-#Lmargin-#Rmargin
pageh=PrinterPageHeight()-#Tmargin-#Bmargin
StartDrawing(PrinterOutput())
; !!! DrawingFont(LoadFont(0, "Arial", 10))
linenumw=TextWidth("1999 ") ; Width of line number column
printw=pagew-linenumw ; Width available for printing file text
lineh=TextHeight("bgj_~QX")+#gap
lpp=(pageh+#gap)/lineh ; Lines that will fit on a page
;}
;- Build print lines in a linked list
If ReadFile(#file, path$)=0: End: EndIf ; Quit without error message
While Not Eof(#file)
ln$=RTrim(ReadString(#file)) ; Preserve any whitespace on the left
; If using PureBUILD, try to get the build number
If FindString(LCase(ln$), "purebuild plugin", 1)
p=FindString(LCase(ln$), "purebuild build =", 1)
If p
build$=" Build "+Str(Val(Mid(ln$,p+17,9999)))
EndIf
EndIf
overflow$="#" ; Not a continuation line
linenum+1
; Does the line need to be split because it is too long for the page width?
Repeat
If TextWidth(ln$)<=printw ; If line will fit on page
If linenum>=linefrst And linenum<=linelast
AddElement(lines$()): lines$()=overflow$+ln$
EndIf
ln$=""
Else ; Line too wide for page
cut=Len(ln$) ; Point [just before] where the line will eventually be cut
Repeat ; Large steps
cut-12 ; New trial cut point
Until TextWidth(Left(ln$,cut))<=printw ; Until it will fit
cut+12
Repeat ; Small steps
cut-1 ; New trial cut point
Until TextWidth(Left(ln$,cut))<=printw ; Until it will fit
; Try not to split the last word, except at a hyphen
For p=cut To cut-12 Step -1
If FindString(" -_"+#TAB$, Mid(ln$,p,1), 1) ; If whitespace, hyphen or underscore
cut=p: Break ; Found a better cut point
EndIf
Next p
; Now cut the line, removing trailing whitespace
tmp$=RTrim(Left(ln$, cut))
If overflow$="+" ; If a continuation line
If Len(tmp$) ; Ignore empty continuation lines
If linenum>=linefrst And linenum<=linelast
AddElement(lines$()): lines$()=overflow$+tmp$
EndIf
EndIf
Else ; Not a continuation line
whitespace$=Left(tmp$, Len(tmp$)-Len(LTrim(tmp$))) ; Remember the leading whitespace
If linenum>=linefrst And linenum<=linelast
AddElement(lines$()): lines$()=overflow$+tmp$
EndIf
overflow$="+"
EndIf
ln$=LTrim(Mid(ln$,cut+1,9999)) ; Build the next continuation line
If Len(ln$): ln$=whitespace$+#continue$+ln$: EndIf ; Prepend the same leading whitespace
EndIf
Until Len(ln$)=0
Wend
CloseFile(#file)
;}
;- Print the lines
; Calculate the number of pages to be printed
pages=(ListSize(lines$())-1)/(lpp-2)+1 ; The -2 allows for the title lines on each page
; Calculate the start position of the [nearly] right-aligned page number
pagenumx=#Lmargin+pagew-TextWidth(Str(pages)+" of "+Str(pages))
; Fit the title [and build number] into the width available
title$+build$
titlew=pagenumx-#Lmargin-40
If TextWidth(title$)>titlew ; If too wide
titlew-TextWidth("...")
Repeat
title$=Mid(title$, FindString(title$,"\",2), 999) ; Truncate at left-most "\"
Until TextWidth(title$)<=titlew ; Until it will fit
title$="..."+title$ ; Prepend "..."
EndIf
; Now do the printing
linenum=linefrst-1
ForEach lines$()
If line=0 ; If starting a new page
pagenum+1
DrawText(#Lmargin, y, title$) ; Print title [and build number]
DrawText(pagenumx, y, Str(pagenum)+" of "+Str(pages)) ; Print page number
line=2: y+lineh*2 ; Leave a blank line
EndIf
If Left(lines$(),1)="#" ; If not a continuation line
linenum+1
DrawText(#Lmargin+TextWidth("1999")-TextWidth(Str(linenum)), y, Str(linenum)) ; "Print" linenumber
EndIf
DrawText(#Lmargin+linenumw, y, Mid(lines$(),2,9999)) ; "Print" text to the right of the line number column
line+1: y+lineh
If line>=lpp ; If the current page is full
line=0: y=#Tmargin
NewPrinterPage()
EndIf
Next lines$()
StopDrawing()
StopPrinting()
End
;}
File -> Preferences -> Editor -> Folding
Ensure ;- is on the list of Folding Start Keywords.
Ensure ;} is on the list of Folding End Keywords.
If the plugin fails to print anything, the probability is that a bug may exist in these lines of code:
Code: Select all
For p=1 To 2
tmp$ = ProgramParameter(p)
If FindString(LCase(tmp$), "\purebasic_tempfile", 1) ; If a temporary filename
path$=tmp$
ElseIf Len(tmp$)
title$=tmp$
EndIf
Next p
If path$="": End: EndIf ; Quit without error message
If FileSize(path$)<=0: : End: EndIf ; Quit without error message
Anthony Jordan
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
It's nicer to read on paper than screen. 
Also...
Once it's in print I think (due to technicalities in some countries), you have a better copyright case.
Also, some people send programs to themselves (with the post office seal on the envelope seal) to prove copyright. I used to do this with game ideas before showing them to publishers. Chemical based optical discs (CDR) can fade or reset after a while - I have discs only a year old that are unreadable. Magnetic media reverts to it's natural state over time - take a look at an old vhs tape. Paper and Ink seems to last the longest.

Also...
Once it's in print I think (due to technicalities in some countries), you have a better copyright case.
Also, some people send programs to themselves (with the post office seal on the envelope seal) to prove copyright. I used to do this with game ideas before showing them to publishers. Chemical based optical discs (CDR) can fade or reset after a while - I have discs only a year old that are unreadable. Magnetic media reverts to it's natural state over time - take a look at an old vhs tape. Paper and Ink seems to last the longest.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
It is useful if there are extensive changes being made to code. The changes can be made on paper where you can see what was, and what will be, at the same time. This can then be used as a checklist to make the changes and verify they are completed correctly.
It is also useful to understand code because it can be easier to scroll on paper than on the screen, especially if 3 or more points need to be examined at the same time.
It is also useful to understand code because it can be easier to scroll on paper than on the screen, especially if 3 or more points need to be examined at the same time.
-
- Enthusiast
- Posts: 203
- Joined: Sat May 23, 2009 4:39 am
Yes, I know all that about backup reasons. It just reminds me of the 70s and
80s where I typed in programs from computer magazines.
But in this day
and age, apps are generally huge. If I printed my flagship app, it uses 252
pages of A4 size paper. Imagine typing that in! And what would happen to
all my included graphics and files? You can't print them out... well, unless
you convert them all to Data blocks first (which is a good idea, actually).
Side-note: Plain text files are also 100% future-proof.
80s where I typed in programs from computer magazines.

and age, apps are generally huge. If I printed my flagship app, it uses 252
pages of A4 size paper. Imagine typing that in! And what would happen to
all my included graphics and files? You can't print them out... well, unless
you convert them all to Data blocks first (which is a good idea, actually).
Side-note: Plain text files are also 100% future-proof.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
-
- Enthusiast
- Posts: 203
- Joined: Sat May 23, 2009 4:39 am
Why would you type it in? Even the super budget printers have scanners and copiers built in. And they generally have feeders. They also usually come with some cheapo OCR software.If I printed my flagship app, it uses 252
pages of A4 size paper. Imagine typing that in!
I have had no problems automatically scanning and converting 30 year old source code into a text file.
Nope, because the media they are stored on isn't future-proof.Plain text files are also 100% future-proof.
> Why would you type it in?
True, I don't have a printer so I forgot all about OCR.
> the media they are stored on isn't future-proof
Neither is paper. It can fade, as does the ink on them, and can be burnt,
wet, shredded, etc. A plain text file on disc, in the same room as a printout
on paper, has exactly the same level of risk. Fire and water will destroy both
just like that (snaps fingers). However, the text file has the advantage that
you can e-mail it offsite to another location, just like that (snaps again).
True, I don't have a printer so I forgot all about OCR.
> the media they are stored on isn't future-proof
Neither is paper. It can fade, as does the ink on them, and can be burnt,
wet, shredded, etc. A plain text file on disc, in the same room as a printout
on paper, has exactly the same level of risk. Fire and water will destroy both
just like that (snaps fingers). However, the text file has the advantage that
you can e-mail it offsite to another location, just like that (snaps again).

I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
-
- Enthusiast
- Posts: 203
- Joined: Sat May 23, 2009 4:39 am
Neither is paper. It can fade, as does the ink on them, and can be burnt,
wet, shredded, etc.
That is not what future-proof means.
Paper has over a 100 year shelf-life. Disc and Disks still do not have that long of lifespan.A plain text file on disc, in the same room as a printout
on paper, has exactly the same level of risk.
A 100 years from now, you will still be able to read that piece of paper. Even if the storage media for the text files still works, you may not be able to read that media format in the future.
As for age, I have several books that are 100-150 years old (long before the advent of acid-free paper). Even though they are yellowed and faded, they still scan and OCR reads the scans just fine.