Board index » delphi » How would I go about doing the following...

How would I go about doing the following...

You could pass the filename on the command-line.
Use ParamCount and ParamStr to retreive the parameters on the command-line.

"Leon Carson" <m...@here.NOSPAM> schreef in bericht
news:390e151b.56833888@news1.qc.sympatico.ca...

Quote
> Hello,
> I just finished writing a little text editor and associated text files
> to it in Windows. When I launch a text file Windows starts my
> application but it doesn't load the file. How do I get it display the
> text file? Just like Notepad does.

> Thanks for taking the time to read my post.

 

Re:How would I go about doing the following...


Quote
>When I launch a text file Windows starts my
>application but it doesn't load the file

Windows sends the full-path name of the file as a command-line
parameter, you just need to read it with ParamCount and ParamStr.

hth

Ged

Re:How would I go about doing the following...


Leon Carson skrev i meddelelsen <390f224b.935...@news1.qc.sympatico.ca>...

Quote
>On Mon, 1 May 2000 13:36:15 +0100, "ged" <sorry....@many.weirdos>
>wrote:

>>>When I launch a text file Windows starts my
>>>application but it doesn't load the file

>>Windows sends the full-path name of the file as a command-line
>>parameter, you just need to read it with ParamCount and ParamStr.

>Ok. I did that. One problem though. Depending on the text file's
>filename ParamStr(1) returns something like this 'C:\My' when the path
>is 'C:\My Documents\'. Any idea on how I can get it to return the
>complete path? I checked D help and it states:

> "Note: Use double quotes to wrap multiple words as one parameter
>(such as long file names containing spaces)"

>Use double quotes where? Around ParamStr(x)? IE "ParamStr(x)"?

>I'm sorry for the stupid questions but this is still pretty new to me.

No, use double quotes around a filename containing space(s).

program.exe "c:\My Documents"

/Morten Lassen
mor...@lassen.as

-if it works the first time; check it again!

Re:How would I go about doing the following...


:Leon Carson <m...@here.NOSPAM> schrieb in im Newsbeitrag:
390f224b.935...@news1.qc.sympatico.ca...
: On Mon, 1 May 2000 13:36:15 +0100, "ged" <sorry....@many.weirdos>
Quote
: wrote:

:
: >>When I launch a text file Windows starts my
: >>application but it doesn't load the file
: >
: >Windows sends the full-path name of the file as a command-line
: >parameter, you just need to read it with ParamCount and ParamStr.
:
: Ok. I did that. One problem though. Depending on the text file's
: filename ParamStr(1) returns something like this 'C:\My' when the path
: is 'C:\My Documents\'. Any idea on how I can get it to return the
: complete path? I checked D help and it states:
:
:  "Note: Use double quotes to wrap multiple words as one parameter
: (such as long file names containing spaces)"
:
: Use double quotes where? Around ParamStr(x)? IE "ParamStr(x)"?
:
: I'm sorry for the stupid questions but this is still pretty new to me.

As Morten says you need to edit the entry for the file type.
I don't know the English words for the entries to be edited but in your
"folder options" there might be a tab for "file types" and for each file
type a "action"...
Just enter the double quotes in the "Open" action...

There might be something like "Application for this action:" where you
entered the name of your editor...
C:\Program Files\YourEditor.exe "%1"

That will do the job right...
Hth,
Matthias.

Re:How would I go about doing the following...


Quote
"Leon Carson" <m...@here.NOSPAM> wrote in message

news:390f224b.935022@news1.qc.sympatico.ca...

Quote
> Ok. I did that. One problem though. Depending on the text file's
> filename ParamStr(1) returns something like this 'C:\My' when the path
> is 'C:\My Documents\'. Any idea on how I can get it to return the
> complete path? I checked D help and it states:

var
  tmpcount:integer;
 fname:string;
begin

For TmpCount:=1 do ParamCount do
  fname:=fname+ParamStr(TmpCount);

--
Sven Tore Iversen
mai...@sventore.com
http://www.sventore.com

Re:How would I go about doing the following...


Possibly....
var
  tmpcount:integer;
  fname:string;
begin
For TmpCount:=1 do ParamCount do
  fname:=fname + ' ' + ParamStr(TmpCount);
fname:=trim(fname);

Sven Tore Iversen <mai...@sventore.com> wrote in message
news:YJGP4.2029$kF4.35585@news1.online.no...

Quote

> "Leon Carson" <m...@here.NOSPAM> wrote in message
> news:390f224b.935022@news1.qc.sympatico.ca...
> > Ok. I did that. One problem though. Depending on the text file's
> > filename ParamStr(1) returns something like this 'C:\My' when the path
> > is 'C:\My Documents\'. Any idea on how I can get it to return the
> > complete path? I checked D help and it states:

> var
>   tmpcount:integer;
>  fname:string;
> begin

> For TmpCount:=1 do ParamCount do
>   fname:=fname+ParamStr(TmpCount);

> --
> Sven Tore Iversen
> mai...@sventore.com
> http://www.sventore.com

Other Threads