Solved

How do i get my (writen) Plain text editor to print at the command line?

Posted on 1998-09-05
8
142 Views
Last Modified: 2010-04-06
How do i get my (writen) Plain text editor to print at the command line, Like notepad when a mytexteditor.exe /p.???
0
Comment
Question by:hyper66
  • 3
  • 3
  • 2
8 Comments
 
LVL 3

Expert Comment

by:mirek071497
ID: 1338713
You must say more what you need.
For parsing command line you have ParamCount and ParamStr - however what you need more ?
if the program can apear on the desktop when printing ? or he need to be hidden ?
To many results I getting whent trying to give you some answer ;)
0
 
LVL 3

Accepted Solution

by:
Matvey earned 60 total points
ID: 1338714
Hi guys, glad to see you Mirek. What you could do:

1) Best in the .DPR itself, befor form showup, put a check for the command line parameters:
 
  if ParamStr(1)='/p' then printfile(ParamStr(2));

2) Define the printfile procedure:

procedure printfile(filename: string);
var s: string;
    printer, t: textfile;
begin
  try
    assignPrn(printer);
    rewrite(printer);
    reset(t, FileName);
    while not eof(t) do begin
      readln(t, s);
      writeln(printer, s);
    end;
  finally
    closefile(t);
    closefile(printer);
  end;
end;

c u, Matvey
0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1338715
nice to see you Matvey - too ;) do you log to the delphi.magsoft.com.pl ?
I have some problems with hackers because our start passwords is not very good ;(
please login and change the password - the rest can wait.
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1338716
What do I have to do exactly? I'm not very in the middle of the business right now :(
0
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.

 
LVL 3

Expert Comment

by:mirek071497
ID: 1338717
hi Matvey.
the best way is to read the : http://delphi.magsoft.com.pl/board.shtml

hyper66 - sorry for this private comments.
0
 

Author Comment

by:hyper66
ID: 1338718
How do i get this code into my for so that when i click on a text file it will load fine in my text editor, and when i use my text editor with the /p and text file my text editor will load and print that file.. the Print code you gave me works but i cannot get it to work in Form show with my other code to display text files when they are clicked.  

procedure TMain.FormShow(Sender: TObject);
Var
F :Integer;
Filename: String;
Begin
if ParamCount >= 1 Then
Begin
Filename := '';
For F := 1 To ParamCount Do
Begin
Filename := Filename + ' ' + ParamStr(F);
End;
 SaveDialog.FileName := Trim(Filename);
 Memo.Lines.LoadFromFile(Trim(Filename));
 Memo.Modified := False;
 MemoChange(Sender);
 OpenDialog.HistoryList.Add(Trim(Filename));
 Caption := 'My Text Editor - ' + '['+ ExtractFileName(Filename)
+']';
End;
End;

How do i insert that code into my other code the right way? and is my code for opening texts file right to begin with?



 
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1338719
LoadFromFile won't work with some files as parameters, it just opens one file at a time. You are trying to post all the command line parameters to it.

I sugest something like:

If ParamCount = 1 then
  <memo.loadfromfile(ParamStr(1))>
else if (ParamStr(1)='/p') and ParamCount=2 then
  <memo.loadfromfile(ParamStr(2))>
  <PrintFile(ParamStr(2))>

-Add all the rest of the code if necesary.

Sorry for your english :), but if you could explain just a bit better... (if you still have problems)

--Matvey
0
 

Author Comment

by:hyper66
ID: 1338720
I have it fixed now, I just was'nt thinking. Thank's :)
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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

914 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

21 Experts available now in Live!

Get 1:1 Help Now