[Gambas-user] How to sent a line line to a lp1 printer and form to lp0 printer directly.

Doriano Blengino doriano.blengino at ...1909...
Wed Sep 23 17:55:16 CEST 2009


Vassilis K ha scritto:
> Actually it is a serial matrix impact printer (panasonic KX-P1150) with a 9 
> pins head and parallel port (LTP)
>   
Just because the printer is like this, you *don't* need to use a SHELL. 
It can be simpler, however.
The device /dev/lp0 is what the name says: "Line Printer" (and I 
underline *line*...). The parallel interface is much more simple than 
the serial one; at least, it does not have a baudrate.
> So I think it is only possible to print with Shell command like
>
> SHELL lp -d ltp2 printfile.ps
>   
...if you want the whole page ejected, perhaps a banner, a print queue 
with retries, then do so.
> I only need an example for this action. If somebody has done it before it 
> would be nice to know how.
> I want to print one line each time without paper feeding. Only one line feed 
> on every action.
> In Visual Basic 6 this command was:
>
> Open "LPT3" For Output As #8
>             Print #8, "Hello World"
>  Close #8
>
> The result was:
>
> Hello World
>
> with page feed. The printer only feeded the current line.
>   

    hPrinter = open "/dev/lp0" for output
    hPrinter.EndOfLine = gb.Windows   ' not really, but the printer
    requires CR-LF
    PRINT #hFile, "test a line: ";              ' does not create a new
    line because of the semicolon
    PRINT #hFile, "this is a test"             ' goes to the next line
    PRINT #hFile, chr$(12);                     ' chances are that this
    line ejects a page
    CLOSE hPrinter                                   ' don't forget to
    close as you are done

If you have two printers, then you can use /dev/lp0 for the first and 
/dev/lp1 for the second.

Regards,
Doriano






More information about the User mailing list