Page 1 of 1

printer begindoc error

Posted: Sun Mar 13, 2022 3:05 am
by alaphate
just two lines code:
-----------------------------
dim p as Printer
p.begindoc
-----------------------------
got error:
Runtime error at position 1887
Access violation at address 00432A4C in module 'printerTest.exe'. Read of address 0000001D

however, with two line code:
-----------------------------
Lprint "hello world"
Lpend
-----------------------------
There's no error, the printer works successfully.

Re: printer begindoc error

Posted: Tue Mar 29, 2022 2:35 pm
by amksoft
Hi,

I think you forgot te tell the system what printer to use:

dim p as printer
p.Printercount Integer R The number of printers that has been installed.
p.Printerindex Integer RW The index of the printer that is used for the printjob.
p.Printers(index) String R The name of the printer with a specified index.

You can use the PrintDialog to select a printer the can be use to set the printer

I think the Lprint prints to the default printer (using the windows printspooler)

Re: printer begindoc error

Posted: Wed Mar 30, 2022 3:56 pm
by alaphate
amksoft:
thanks for the answer, but still got errors
------
dim p as Printer
dim i as long
'list all printers' index and name
for i=0 to p.Printercount-1
showmessage str$(i)+": "+p.printers(i)
next i

'set the printer to use
p.printerindex = 1

p.begindoc
------
got error:
Runtime error at position 1952
Access violation at address 00432A4C in module 'printerTest.exe'. Read of address 0000001D