printer begindoc error

In this category you can exchange your programming questions and solutions.
Post Reply
alaphate
Posts: 9
Joined: Sun Feb 13, 2022 6:10 am

printer begindoc error

Post: # 98373Post alaphate
Sun Mar 13, 2022 3:05 am

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.

amksoft
Posts: 4
Joined: Tue Mar 29, 2022 1:38 pm

Re: printer begindoc error

Post: # 98378Post amksoft
Tue Mar 29, 2022 2:35 pm

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)

alaphate
Posts: 9
Joined: Sun Feb 13, 2022 6:10 am

Re: printer begindoc error

Post: # 98379Post alaphate
Wed Mar 30, 2022 3:56 pm

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

Post Reply