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;