Solved

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

Posted on 1998-09-05
8
144 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi TcxGrid group footer summary 3 316
indy Tmemory stream non latin charcter issue 2 121
Magic Software info 18 138
How to convert memory stream to PDF file 6 108
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

839 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