Author |
Topic: printing to printer (Read 1922 times) |
|
Rod
Full Member
member is offline


Gender: 
Posts: 110
|
 |
Re: printing to printer
« Reply #2 on: Jun 18th, 2015, 09:37am » |
|
Adding to that you can get a bit fancier with a graphicbox print. This is the printform.bas example tweaked a little.
Code: open "test.txt" for output as #t
#t "0,Start, 0, 0, 0"
#t "P,Jones,Joyce,22,5.6"
#t "P,Newman,Bill,26,0.35"
#t "P,Abercrombe,Tom Cruise,35,1254.25"
#t "P,Belton,Mindy,28,1245687.8"
#t "P,Doyle,Barbara,15,1040.05"
close #t
open "test.txt" for input as #t
'printform.bas
'This example program shows how to use a graphics window to produce
'printable form without using PCL or graphics characters. Different
'fonts and colors are used.
nomainwin
WindowWidth = 800
WindowHeight = DisplayHeight
open "Printable Form" for graphics as #form
#form "trapclose [quit]"
#form "down"
#form "backcolor 220 220 220"
#form "size 2"
#form "place 1 1 ; boxfilled 700 110"
#form "font arial 16 bold"
#form "place 20 34"
#form "\Software Mail-in Order Form"
#form "font arial 10"
#form "\Mega2 Super Corporation\PO Box 1029391\Industrialtown, PA 11701\"
#form "backcolor white"
#form "place 1 110"
#form "boxfilled 700 471"
#form "place 1 471"
#form "boxfilled 700 970"
#form "color black ; place 20 490 ; font courier new"
while eof(#t)=0
line input #t,t$
if left$(t$,1)="P" then
p$=left$(trim$(word$(t$,2,","))+space$(24),24)
p$=p$+left$(trim$(word$(t$,3,","))+space$(24),24)
p$=p$+left$(trim$(word$(t$,4,","))+space$(4),4)
p$=p$+using("########.##",val(word$(t$,5,",")))
#form "\";p$
end if
wend
#form "flush"
confirm "Send to printer?"; answer
if answer then #form "print svga"
wait
close #form
close #t
end
[quit]
close #form
close #t
end
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: printing to printer
« Reply #3 on: Jun 18th, 2015, 11:05am » |
|
on Jun 18th, 2015, 09:37am, Rod wrote:| Adding to that you can get a bit fancier with a graphicbox print. |
|
Not necessarily such a good idea with LBB. Because (unlike LB/JB) you can change attributes - bold, italics etc. - within a page I would normally recommend that text only printout be done using LPRINT - not least because then there's no need to display the output on the screen first!
Only if you want to mix text and graphics would I use the printform technique, and not necessarily even then, because in LBB you can mix both kinds of output on the same sheet (use the NODUMP qualifier with the PRINT command).
Richard.
|
|
Logged
|
|
|
|
tsh73
Full Member
member is offline


Gender: 
Posts: 210
|
 |
Re: printing to printer
« Reply #4 on: Jun 18th, 2015, 11:47am » |
|
Quote:| Because (unlike LB/JB) you can change attributes - bold, italics etc. - within a page |
|
Richard, could you give an example or point where it is described?
EDIT found it by search for "LPRINT" at "New features" at Help file
|
| « Last Edit: Jun 18th, 2015, 11:52am by tsh73 » |
Logged
|
|
|
|
hammerjit
New Member
member is offline


Posts: 26
|
 |
Re: printing to printer
« Reply #5 on: Jun 19th, 2015, 06:22am » |
|
thanks tsh73, got my code to work with your help.
Just a quick question, is there a command to forced printout on landscape mode without user interaction?
|
|
Logged
|
|
|
|
tsh73
Full Member
member is offline


Gender: 
Posts: 210
|
 |
Re: printing to printer
« Reply #6 on: Jun 19th, 2015, 07:13am » |
|
Quote:| is there a command to forced printout on landscape mode without user interaction? |
|
I have no idea but search at Liberty Basic forum returned this thread Landscape Printing
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: printing to printer
« Reply #7 on: Jun 19th, 2015, 09:22am » |
|
on Jun 19th, 2015, 06:22am, hammerjit wrote:| is there a command to forced printout on landscape mode without user interaction? |
|
It's a bit of a kludge, but you could use the published BBC routine and add the 'BBC BASIC escape' character to every line:
Code:SUB landscape
!LOCAL psd%, dm%
!DIM psd% LOCAL 83
!!psd% = 84
!psd%!16 = 1024
!SYS "PageSetupDlg", psd%
!SYS "GlobalLock", psd%!8 TO dm%
!dm%!40 = 1
!dm%?44 = 2
!SYS "ResetDC", @prthdc%, dm%
!SYS "GlobalUnlock", psd%!8
!SYS "GlobalFree", psd%!8
!SYS "GlobalFree", psd%!12
!*MARGINS 10,10,10,10
END SUB Richard.
|
|
Logged
|
|
|
|
hammerjit
New Member
member is offline


Posts: 26
|
 |
Re: printing to printer
« Reply #8 on: Jun 23rd, 2015, 01:57am » |
|
Thanks Richard...it works
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: printing to printer
« Reply #9 on: Jun 23rd, 2015, 05:47am » |
|
In an ideal world there should be some way of setting, in code, all the things that the user can set using PAGESETUPDIALOG (i.e. the paper size, orientation and margins). Can anybody think of a sensible syntax for this?
Richard.
|
|
Logged
|
|
|
|
tsh73
Full Member
member is offline


Gender: 
Posts: 210
|
 |
Re: printing to printer
« Reply #10 on: Jun 23rd, 2015, 07:00am » |
|
Quote:| Can anybody think of a sensible syntax for this? |
|
Named parameters, like in VBA? Not listed get default values. If position accept list, like list of pages, let it be string "1-5, 7, 9".
Or just one big string with named parameters list inside ("pages = 1-5, 7, 9 ; orientation = landscape; leftMargin = 1.5 cm")
|
| « Last Edit: Jun 23rd, 2015, 07:01am by tsh73 » |
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: printing to printer
« Reply #11 on: Jun 23rd, 2015, 11:36am » |
|
on Jun 23rd, 2015, 07:00am, tsh73 wrote:Or just one big string with named parameters list inside ("pages = 1-5, 7, 9 ; orientation = landscape; leftMargin = 1.5 cm") |
|
So, for consistency with other LB printer settings, you are proposing something like:
Code:PrinterSetup$ = "orientation = landscape; leftMargin = 1.5 cm" Richard.
|
|
Logged
|
|
|
|
tsh73
Full Member
member is offline


Gender: 
Posts: 210
|
 |
Re: printing to printer
« Reply #12 on: Jun 23rd, 2015, 12:16pm » |
|
well, kind of. May be - for consistency with LB GUI commands - get rid of "=", so it becames Code:PrinterSetup$ = "orientation landscape; leftMargin 1.5 cm" ?
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: printing to printer
« Reply #13 on: Jun 23rd, 2015, 3:57pm » |
|
on Jun 23rd, 2015, 12:16pm, tsh73 wrote:| May be - for consistency with LB GUI commands |
|
I think I'd be inclined to simplify even further:
Code: PrinterName$ = "DoPDF v7"
PrinterFont$ = "Arial 12 bold"
PrinterColor$ = "blue"
PrinterSetup$ = "landscape 15 10 10 10" I should add that at present I have no plans for a new release of LBB but I'll make a mental note of the possibility of such additions should the atmosphere change.
Richard.
|
|
Logged
|
|
|
|
tsh73
Full Member
member is offline


Gender: 
Posts: 210
|
 |
Re: printing to printer
« Reply #14 on: Jun 23rd, 2015, 4:18pm » |
|
Code:
PrinterName$ = "DoPDF v7"
PrinterFont$ = "Arial 12 bold"
PrinterColor$ = "blue"
PrinterSetup$ = "landscape 15 10 10 10"
Doesn't it look like too many reserved words?
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: printing to printer
« Reply #15 on: Jun 23rd, 2015, 7:36pm » |
|
on Jun 23rd, 2015, 4:18pm, tsh73 wrote:| Doesn't it look like too many reserved words? |
|
What problems do you see, and what is the alternative? Combining PrinterColor$ and PrinterSetup$ in a single new command seems to me illogical and inconsistent with the rest of LB, and the compatibility issues arising from having both are minimal.
Richard.
|
|
Logged
|
|
|
|
tsh73
Full Member
member is offline


Gender: 
Posts: 210
|
 |
Re: printing to printer
« Reply #16 on: Jun 23rd, 2015, 8:03pm » |
|
I see single entity - printer - and several keywords associated with it PrinterName$ PrinterFont$ PrinterColor$ PrinterSetup$
Suppose you will want to add two side printing or DPI setting or paper size - will you add still another word?
I think pack it all in single string is better, much like OPEN COM from LBB helpfile: Code:open "COMn: [baud=b] [parity=p] [data=d] [stop=s]
[to=on|off] [xon=on|off] [odsr=on|off] [octs=on|off]
[dtr=on|off|hs] [rts=on|off|hs|tg] [idsr=on|off]"
|
| « Last Edit: Jun 23rd, 2015, 8:03pm by tsh73 » |
Logged
|
|
|
|
|