Solved

I/O Error 21 while printing to a dotmatrix

Posted on 2003-11-01
6
727 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 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

10 Experts available now in Live!

Get 1:1 Help Now