Solved

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

Posted on 1998-09-05
8
145 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
Independent Software Vendors: 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!

 
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

Technology Partners: 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

Title # Comments Views Activity
HTML text in the body of an email (delphi code) 12 210
Run video youtube webbrowse 10 73
Delphi: making a BW image transparent 10 88
Broadcast a message using ICS 2 20
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

713 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