[Gambas-user] How to sent a line line to a lp1 printer and form to lp0 printer directly.
Doriano Blengino
doriano.blengino at ...1909...
Fri Sep 25 07:26:17 CEST 2009
Vassilis K ha scritto:
> Is there any chance to find out why I get the message:
> Access forbidden at the following Sub? And of course to make it work?
> PUBLIC SUB bEktiposi_Click()
> DIM hPrinter AS Printer
> DIM hFile AS File
> hPrinter = OPEN "dev/lp1" FOR OUTPUT
> hPrinter.EndOfLine = gb.Windows
> PRINT #hFile, "test a line: ";
> CLOSE hPrinter
> END
>
> It is compiled but it stops when bEtiposi Button is clicked
> at line :
> hPrinter = OPEN "dev/lp1" FOR OUTPUT
> with the message:
> " Access Forbidden. "
>
I missed one important thing.
Don't confuse hPrinter with Printer - in one of my previous messages I
used the name hPrinter, because it was intended as a handle to a
printer, but it was a *file*.
In your code you DIM hPrinter as Printer, and then use it as a file. May
be gambas gets confused by this - don't do so. A Printer is a different
thing than a file or stream. I repeat: we are using the printer through
the file system, not through Printer class.
Next problem could be an access privilege on the file you are trying to
open (/dev/lp1 in this case). If the problem persists, make a
ls -l /dev/lp*
to see what the privileges are, and post the result to this list.
Regards,
--
Doriano Blengino
"Listen twice before you speak.
This is why we have two ears, but only one mouth."
More information about the User
mailing list