POS machine control cash box, guest display, printer, ticket printing in Delphi

Source: Internet
Author: User

1. Control the customer display of the POS machine

Procedure tfrmmain. showmoney (money_port: string; money_string: string );
// Moneey_port Gu Xian interface COM1 or com2 money_string Gu Xian display content
VaR
Prnfilename: textfile;
Begin
Assignfile (prnfilename, money_port );
Printer. Canvas. Font. Name: = ' ';
Printer. Canvas. Font. Size: = 8;
Printer. Canvas. Font. charset: = gb2312_charset;
Rewrite (prnfilename );
Write (prnfilename, CHR (12); // clear Gu Xian
Write (prnfilename, CHR (27) + CHR (81) + CHR (65) + money_string + CHR (13); // display information
CloseFile (PRNFileName );
End;

2. Printing without changing pages

Procedure TFrmMain. AddPrintStrings (Strings: TStrings );
Var
Prn: TextFile;
I: word;
Begin
Assignfile (Prn, 'lpt1 ');
Printer. Canvas. Font. Name: = ' ';
Printer. Canvas. Font. Size: = 9;
Printer. Canvas. Font. Charset: = GB2312_CHARSET;
Try
Rewrite (Prn );
Try
For I: = 0 to Strings. Count-1 do
Writeln (Prn, Strings. Strings [I]);
Finally
CloseFile (Prn );
End;
Except
On EInOutError do
MessageBox (Handle, PChar ('text printing error! '), 'Warning', MB_ICONEXCLAMATION or MB_ OK );
End;
End;

3. take the form of paper for Printing

Procedure TFrmMain. PrintStrings (Strings: TStrings );
Var
Prn: TextFile;
I: word;
Begin
AssignPrn (Prn );
Try
Rewrite (Prn );
Printer. Canvas. Font. Name: = ' ';
Printer. Canvas. Font. Size: = 9;
Printer. Canvas. Font. Charset: = GB2312_CHARSET;
Try
For I: = 0 to Strings. Count-1 do
Writeln (Prn, Strings. Strings [I]);
Finally
CloseFile (Prn );
End;
Except
On EInOutError do
MessageBox (Handle, PChar ('text printing error! '), 'Warning', MB_ICONEXCLAMATION or MB_ OK );
End;
End;

4. Open the cash box

Procedure TFrmMain. OpenMoneyBox;
Var F: TextFile;
PDStr: string;
Begin
// The cash box function is displayed.
PDStr: = Chr (27) + 'P' + Chr (0) + Chr (60) + Chr (255 );
AssignFile (F, 'lpt1 ');
Rewrite (F );
Write (F, PDStr );
CloseFile (F );
End;

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.