to 江南大米;
现在调试 通过,就是不输出,
procedure Tform1.PrintFile(AFileToPrint: string);
var
Port, FileToPrint: TextFile;
ALine: string;
begin
AssignFile(FileToPrint, AFileToPrint);
Reset(FileToprint); ######################在此处报错,提示输出 I/O端口错误
但是我的打印机已经接上了。
AssignFile(Port, 'LPT1');
Rewrite(Port);
while not Eof(FileToPrint) do
begin
Readln(FileToPrint, ALine);
Writeln(Port, ALine);
end;
CloseFile(Port);
CloseFile(FileToPrint);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
MerName, outfile,CompanyTitle:string;
F:TEXTFILE;
len,CardPayment:integer;
begin
CardPayment:=1002;
EdCash.Text:=inttostr(22);
STOpID.Caption :='111';
STSaleID.Caption :='2222';
STSaleDate.Caption :='2003-01-01' ;
STHj.Caption :='321';
STRl.Caption :='33';
STSs.Caption :='4343';
STBack.Caption :='333';
// 打印小单
// 输出到文本,稍后再输出到LPT1端口;
OutFile:=ExtractFilePath(Application.ExeName)+'output.txt';
AssignFile(F, OutFile);
Rewrite(F);
CompanyTitle:=StringOfChar(' ', (32-Length(CompanyTitle)) div 2)+CompanyTitle;
Writeln(F, CompanyTitle);
Writeln(F,'--------------------------------');
// Writeln(F,'收银机:'+EdPosID.Text+' 单号:'+EdSaleID.Text);
// Writeln(F,'收银员:'+EdOpID.Text+ ' 日期:'+EdSaleDate.Text);
Write(F,'收银员:', Format('%-10s', [STOpID.Caption]));
Writeln(F, '单号:'+STSaleID.Caption);
Writeln(F,'日期:'+STSaleDate.Caption+ ' 时间:'+FormatDateTime('hh:mm:ss', Now));
Writeln(F,'--------------------------------');
// 12345678901234567890123456789012
Writeln(F,'商品名称 数量 单价 金额');
ADSSaleList.DisableControls;
ADSSaleList.First;
while not ADSSaleList.Eof do
begin
MerName:=ADSSaleList.FieldValues['sp_name'];
len:=Length(MerName);
if len < 18 then
MerName:=MerName+StringOfChar(' ', 18-len);
if (len mod 2) = 0 then
Write(F, Copy(MerName, 1, 18))
else
Write(F, (Copy(MerName, 1, 17)+' '):18);
Write(F, ADSSaleList.FieldValues['sp_jj']:2);
Write(F, FormatFloat('0.0', ADSSaleList.FieldValues['sp_pfj']):6);
Writeln(F, FormatFloat('0.0', 5):6);
ADSSaleList.Next;
end;
ADSSaleList.EnableControls;
Writeln(F,'--------------------------------');
Writeln(F,'合计:',STHj.Caption:8, ' 让利:', STRl.Caption:8);
Writeln(F,'实收:',STSs.Caption:8, ' 金卡:',
FormatCurr('0.00', CardPayment):8
);
Writeln(F,'现金:',
FormatCurr('0.00', StrToCurr(EdCash.Text)-CardPayment):8,
' 找补:', STBack.Caption:8
);
Writeln(F,' '); //空行,添加或减少空行即可控制出纸多少。
PrintFile(Outfile); // 输出文件到打印口
end;