?
Solved

I/O Error 21 while printing to a dotmatrix

Posted on 2003-11-01
6
Medium Priority
?
735 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 336 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 332 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 332 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

770 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