Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Translate code from VB to Delphi for OPOS

568 views
Skip to first unread message

Carlos Aneses

unread,
Nov 6, 2001, 7:32:42 PM11/6/01
to
I copy an example of how the OPOS would work on VB. How does that is
tranlated to Delphi?

'Set the specified printer driver as the "default printer."
For Each prnPrinter In Printers
If prnPrinter.DeviceName = "EPSON TM-200B No cut" Then
Set Printer = prnPrinter
Exit For
End If
Next

Selecting the Paper Source:

The following code will set or change the selected paper source on the
printer.

'Selecting the paper source.
Printer.FontSize = 10 'Set up the font size.
Printer.FontName = "control" 'Select the control font
Printer.Print "3 " 'Specify the desired source...see below comment.
'Print something.
Printer.FontSize = 10 'Select the text font size.
Printer.FontName = "20 cpi" 'Select the text font.
Printer.Print "test print" 'Enter and print the text string.
'1: Journal
'2: Receipt
'3: Both


Cutting the Paper:
The following code causes the printer to cut the paper.


Printer.FontSize = 10 'Set up the control font.
Printer.FontName = "control" 'Control Font.
Printer.Print "F" 'Use special-function character to cut the paper.
Printer.EndDoc
'F: Full cut
'P: Partial cut


Opening the Cash Drawer:


The next example shows how to open the desired cash drawer at the desired
speed.

Printer.FontSize = 10 'Set up the control font.
Printer.FontName = "control"
Printer.Print "A" 'Use special-function character to open the cash drawer.
Printer.EndDoc
'A: Open drawer 1 at 50ms.
'B: Open drawer 1 at 100ms.
'C: Open drawer 1 at 150ms.
'D: Open drawer 1 at 200ms.
'E: Open drawer 1 at 250ms.
'a: Open drawer 2 at 50ms.
'b: Open drawer 2 at 100ms.
'c: Open drawer 2 at 150ms.
'd: Open drawer 2 at 200ms.
'e: Open drawer 2 at 250ms.


Please refer to the driver User's Manual included with the TM Windows Driver
Set for further examples and explanations. The TM Windows Driver Set also
includes a complete functional Visual Basic sample application.


Zayin Krige

unread,
Nov 7, 2001, 4:18:12 AM11/7/01
to
read the help on the "TPrinter" object in delphi - it should have all the
examples you need

"Carlos Aneses" <carl...@prtc.net> wrote in message
news:3be84868_2@dnews...

Ernesto D'Spirito

unread,
Nov 7, 2001, 9:08:13 AM11/7/01
to
The first part is more or less easy to translate:

var
i: integer;
begin
// Set the specified printer driver as the current printer.
for i := 0 to Printer.Printers.Count - 1 do begin
if Printer.Printers[i] = 'EPSON TM-200B No cut' then begin
Printer.PrinterIndex := i;
end;
end;
end;

Printing is a little bit more problematic:

Printer.BeginDoc;
Printer.Canvas.Font.Size := 10; // Set up the font size
Printer.Canvas.Font.Name := 'control'; // Select the control font
Printer.Canvas.TextOut(0,0,'Hello, world!'); // Print some text
Printer.EndDoc;

The problem is that to print different lines you have to keep record
of the coordinates and meassure the height of the text to advance
the coordinates to a new line... It is also possible to print with
Writeln to a text file assigned to the printer device... Anyway, to
print the old fashioned way (printing lines) I would suggest you to
use YAPI instead: http://www.geocities.com/yapisoftware/


Ernesto D'Spirito
Editor, Pascal Newsletter
http://www.latiumsoftware.com/en/

"Carlos Aneses" <carl...@prtc.net> wrote in message
news:3be84868_2@dnews...

Carlos Aneses

unread,
Nov 7, 2001, 4:01:15 PM11/7/01
to
Thanks
Carlos
Ernesto D'Spirito <edsp...@latiumsoftware.com> wrote in message
news:3be93f71_2@dnews...
0 new messages