Solved

I/O Error 21 while printing to a dotmatrix

Posted on 2003-11-01
6
731 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

807 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