Solved

I/O Error 21 while printing to a dotmatrix

Posted on 2003-11-01
6
730 Views
Last Modified: 2007-12-19
Hi,

I m trying to write a network dotmatrix printer named TALLY uses EPSON settings. I m writing from a TMemo to port line by line.

Before using this new printer everything is ok. But now i m getting I/O Error 21.

Could you help me.

My operating system is W2K and i m using Delphi 7.

My code is below.

  Var FileReport : TextFile;

  AssignFile(FileReport, '\\TALLY\P1_T2280-2T');

  Rewrite(FileReport);

  Writeln(FileName, #27, '[7{', #27,'(hex',#27,'1B',#27,'5B',#27,'37',#27,'7B)')
 // this is for selecting printer tractor. because it has three tractor.. it is esc charset of printer

   Writeln(FileReport, #15);
    i := 0;
    while MemoInvoice.Lines.Count > i do
     begin
          S := MemoInvoice.Lines[i];
          Writeln(FileReport, ConvertLineStr(S));
          i := i + 1;
     end;
     Writeln(FileReport, #12);
     CloseFile(FileReport);


Function ConvertLineStr(S : String) : String;
Var
      Artim : Integer;
begin
      For Artim := 1 To Length(S) Do
      begin
            if S[Artim] = 'Ç' then S[Artim] := #128;
            if S[Artim] = 'Þ' then S[Artim] := #158;
            if S[Artim] = 'Ý' then S[Artim] := #152;
            if S[Artim] = 'Ð' then S[Artim] := #166;
            if S[Artim] = 'Ü' then S[Artim] := #154;
            if S[Artim] = 'Ö' then S[Artim] := #153;
            if S[Artim] = 'ç' then S[Artim] := #135;
            if S[Artim] = 'ý' then S[Artim] := #141;
            if S[Artim] = 'ü' then S[Artim] := #129;
            if S[Artim] = 'ö' then S[Artim] := #148;
            if S[Artim] = 'þ' then S[Artim] := #159;
            if S[Artim] = 'ð' then S[Artim] := #167;
      end;
      Result := S;
end;

0
Comment
Question by:fatihguven
6 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 84 total points
ID: 9663568
you use FileName and FileReport


....
  Rewrite(FileReport);

  Writeln(FileName, #27, '[7{', #27,'(hex',#27,'1B',#27,'5B',#27,'37',#27,'7B)')
 // this is for selecting printer tractor. because it has three tractor.. it is esc charset of printer

   Writeln(FileReport, #15);
....

a typo?

additional a had contatanate the string   with + like
  Writeln(FileName, #27+ '[7{'+ #27+'(hex'+#27+'1B'+#27+'5B'+#27+'37'+#27+'7B)')

meikl ;-)
0
 

Author Comment

by:fatihguven
ID: 9663593
first i m using the code
Writeln(FileName, #27, '[7{', #27,'(hex',#27,'1B',#27,'5B',#27,'37',#27,'7B)')

in a separate procedure. So, it is my mistake of asking question. if it is then dephi will give me a compiler error. So, i can define the error.

Second, i tried using  + instead of , but it doesnt work.

Thanks your answer but my problem is still going on.
0
 
LVL 5

Assisted Solution

by:DeerBear
DeerBear earned 83 total points
ID: 9665241
Hi,

Did you try with AssignPrn?

Save the default printer settings, set the new default printer,
use AssignPrn and then reset the printer... should work.

HTH,

Andrew
0
 

Assisted Solution

by:mehdi_m
mehdi_m earned 83 total points
ID: 9674603
the LPT cable maybe matter!

I had your problem, with a LQ-300 dot-matrix printer too.
it was good at first but after some days it starts to error "I/O Error 21" instead of printing. I just change it's LPT cable, and it fixed.

you can try it. it don't have so much cost. ;)
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question