Solved

Print ASCII Files in Delphi 2

Posted on 1997-05-29
2
263 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
Comment Utility
*********   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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video discusses moving either the default database or any database to a new volume.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

12 Experts available now in Live!

Get 1:1 Help Now