Solved

I/O Error 21 while printing to a dotmatrix

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert Jpg /PNG To GIF 5 118
add combobox item based on numbers 9 122
Tembedded WB animatid gifs not animated on some pcs 2 72
Multi-layered image in FireMonkey 9 15
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now