Solved

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

Posted on 1998-09-05
8
141 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
What do I have to do exactly? I'm not very in the middle of the business right now :(
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 3

Expert Comment

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

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…
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…
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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