Solved

Print ASCII Files in Delphi 2

Posted on 1997-05-29
2
283 Views
Last Modified: 2010-04-06
Hello, my name is Angel and I have a problem. I don't know how I can print an ASCII file in Delphi after press a button. I don't want use TPrinter component. I like that result was identical that I wrote in MS-DOS 'print autoexec.bat'.
0
Comment
Question by:Anglaf
2 Comments
 
LVL 4

Expert Comment

by:StevenB
ID: 1336645
*********   See Comment in other instance of this question   *********

(Can I recomend that you mail Customer Support to get this question removed)
0
 
LVL 4

Accepted Solution

by:
erajoj earned 50 total points
ID: 1336646
This will do for 50 pt:

procedure TMainForm.Button12Click(Sender: TObject);
var
  t, lpt: TextFile;
  line  : string;
begin
  if OpenDialog.Execute then try
    AssignFile(t, OpenDialog.Filename);
    AssignFile(lpt, 'LPT1');
    FileMode := 0;
    Reset(t);
    Rewrite(lpt);
    while not EOF(t) do begin
      ReadLn(t, line);
      WriteLn(lpt, line);
    end;
    Write(lpt, #4); // end of transmission
    CloseFile(lpt);
  except
    // trap errors here
  end;
end;

procedure TMainForm.Button13Click(Sender: TObject);
begin
  Winexec('cmd /c print main.txt', SW_HIDE);
end;

/// John

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

756 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