Passing parameters to a program
Moderators: Hacker, petermad, Stefan2, white
- robinsiebler
- Senior Member
- Posts: 460
- Joined: 2003-03-05, 21:04 UTC
Passing parameters to a program
I created a button on the buttonbar for a program called ExamDiff. ExamDiff wants to receive the full path to 2 files. I tried passing %L, but that doesn't work. How do I pass the path and filename for 2 selected files to the program?
Thanks for asking this, so far I tried to use "%p%n %t%n" as parameters but this does not always work.
Sometimes this becomes so annoying that I end up using the right-click and "Send To" with the 2 files in question selected, of course both of them in the same folder but with a different name. But as having them in 2 different panels, like I said, sometimes it works and most, it doesn't.
Does anybody knows a better parameter configuration ?

Sometimes this becomes so annoying that I end up using the right-click and "Send To" with the 2 files in question selected, of course both of them in the same folder but with a different name. But as having them in 2 different panels, like I said, sometimes it works and most, it doesn't.
Does anybody knows a better parameter configuration ?

Memo to Boss : No TC, No Work
Re: Passing parameters to a program
I guess you'd have to select them in source and target window (one file per window) and use like %P and %Mrobinsiebler wrote:I created a button on the buttonbar for a program called ExamDiff. ExamDiff wants to receive the full path to 2 files. I tried passing %L, but that doesn't work. How do I pass the path and filename for 2 selected files to the program?
Afaik TC cannot pass names of selected files to command line (except %L).
Try using lst2str, it's a prog. I wrote exactly for such cases, it has a helpful enough readme; you can download it here:
http://members.lycos.co.uk/maxwish/tc_tools/lst2str.zip
(Maxwish's site, tools section)
Cheers.
http://members.lycos.co.uk/maxwish/tc_tools/lst2str.zip
(Maxwish's site, tools section)
Cheers.
lst2str enhancement
I have similar situation (I just use Norton File Compare (ncompare) instead of ExamDiff).
To compare two files from one pane we can use lst2str tool with %L parameter.
To compare a file from the source pane with a file from the target pane we can use %P,%N,%T,%M parameters.
So we need to create two buttons for these two situations, but I use the following trick to combine them and created one single button with the following parameters:
Command: c:\path\to\lst2str.exe
Parameters: "c:\path\to\ncompare.exe" "%L" %T%M
When I select two files in the source pane lst2str passes them to ncompare via list file (%L), the third file (from the target pane (%T%M)) is ignored.
When I select one file in each pane (or no selection - just files under cursor used) lst2str passes one of them (from the source pane) via list file and the other one (from the target pane) via %T%M.
But there are some problems with lst2str in such usage.
JackFoo, please consider this:
1. No way to pass additional switches because I use switches placeholder to pass additional file.
2. If target file with its path contains spaces this results in the following (lst2str passes "switches" before files):
ncompare.exe c:\target file.txt "c:\source file.txt"
This happens because you think that c:\target file.txt is a set of swithes, but ncompare thinks that c:\target is first file and file.txt is the second one.
3. No way to launch the program (ncompare) maximized. I adore maximized windows
.
4. lst2str is console program and thus I see black window blinking. I don't like that
. Why not to make it Windows app?
To solve these problems I suggest to enhance lst2str (actually I could write such tool myself for my needs but I respect your "copyrights"...
) to receive such parameters:
lst2str.exe [/nnn] [/M] "program.exe" "list.file" ["extra.file"] ["some switches"]
Brackets mean optional parameters.
/M - launch "program.exe" maximized (I don't know how you launch "program.exe" but if you use CreateProcess you can pass SW_MAXIMIZE in STARTUPINFO).
You should produce the following command line for "program.exe":
"file1" "file2" ... "filen" "extra.file" some switches
where "file1" ... "filen" come from the list file.
/nnn is intened for programs that don't allow more than two files on input in command line. Norton File Compare just ignores extra files but probably some other programs will display a warning or smth worse. So this switch limits the maximum number of files produced in "output".
Examples:
lst2str.exe /M /2 "c:\path\to\program.exe" "%L" %T%M
lst2str.exe /18 "c:\path\to\program.exe" "%L"
As you can see I didn't enclosed %T%M in quotes because TC already does this if needed. If I enclose it in quotes, "%T%M" for long file names will yield e.g. ""c:\path to\my file.txt"". So your tool should accepth both quoted and not quoted parameters.
I think other people will thank you for this also. My thanks go here just now!
But if you're too busy or for some other reason cannot do this, let me know and I'll have to do this bunch of work myself
.
To compare two files from one pane we can use lst2str tool with %L parameter.
To compare a file from the source pane with a file from the target pane we can use %P,%N,%T,%M parameters.
So we need to create two buttons for these two situations, but I use the following trick to combine them and created one single button with the following parameters:
Command: c:\path\to\lst2str.exe
Parameters: "c:\path\to\ncompare.exe" "%L" %T%M
When I select two files in the source pane lst2str passes them to ncompare via list file (%L), the third file (from the target pane (%T%M)) is ignored.
When I select one file in each pane (or no selection - just files under cursor used) lst2str passes one of them (from the source pane) via list file and the other one (from the target pane) via %T%M.
But there are some problems with lst2str in such usage.
JackFoo, please consider this:
1. No way to pass additional switches because I use switches placeholder to pass additional file.
2. If target file with its path contains spaces this results in the following (lst2str passes "switches" before files):
ncompare.exe c:\target file.txt "c:\source file.txt"
This happens because you think that c:\target file.txt is a set of swithes, but ncompare thinks that c:\target is first file and file.txt is the second one.
3. No way to launch the program (ncompare) maximized. I adore maximized windows

4. lst2str is console program and thus I see black window blinking. I don't like that

To solve these problems I suggest to enhance lst2str (actually I could write such tool myself for my needs but I respect your "copyrights"...

lst2str.exe [/nnn] [/M] "program.exe" "list.file" ["extra.file"] ["some switches"]
Brackets mean optional parameters.
/M - launch "program.exe" maximized (I don't know how you launch "program.exe" but if you use CreateProcess you can pass SW_MAXIMIZE in STARTUPINFO).
You should produce the following command line for "program.exe":
"file1" "file2" ... "filen" "extra.file" some switches
where "file1" ... "filen" come from the list file.
/nnn is intened for programs that don't allow more than two files on input in command line. Norton File Compare just ignores extra files but probably some other programs will display a warning or smth worse. So this switch limits the maximum number of files produced in "output".
Examples:
lst2str.exe /M /2 "c:\path\to\program.exe" "%L" %T%M
lst2str.exe /18 "c:\path\to\program.exe" "%L"
As you can see I didn't enclosed %T%M in quotes because TC already does this if needed. If I enclose it in quotes, "%T%M" for long file names will yield e.g. ""c:\path to\my file.txt"". So your tool should accepth both quoted and not quoted parameters.
I think other people will thank you for this also. My thanks go here just now!


Valentino. Black Dog,
Would you mind using some brighter color when emphasizing / quoting text? It's almost impossible to see on the dark blue background of the Cobalt template.
TIA
Roman
Would you mind using some brighter color when emphasizing / quoting text? It's almost impossible to see on the dark blue background of the Cobalt template.
TIA
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
2Hacker
No problem. What colors do you see the best? List several ones so I could choose the best for my template also.
No problem. What colors do you see the best? List several ones so I could choose the best for my template also.
How about if I do this? It's quite simple and won't take much time for me. This splashing black window... Windows app can run invisible to user.JackFoo wrote:I don't usually program for windows (more to do with algorithms and such) so it'll remain a console app.
[face=courier]On 06-03-2003 14:23:17 +0000 Hacker wrote:
H> Black Dog,
H> Would you mind using some brighter color when emphasizing
H> / quoting text?
Sorry Jedi, but it's not possible.[/face]
H> Black Dog,
H> Would you mind using some brighter color when emphasizing
H> / quoting text?
Sorry Jedi, but it's not possible.[/face]
[face=courier]The Protoss do NOT run from their enemies.
It is here, that we shall make our stand.[/face]
It is here, that we shall make our stand.[/face]
[face=courier]On 07-03-2003 13:14:02 +0000 Hacker wrote:
H> Black Dog,
H>
Why?
I like maroon
.[/face]
H> Black Dog,
H>

I like maroon

[face=courier]The Protoss do NOT run from their enemies.
It is here, that we shall make our stand.[/face]
It is here, that we shall make our stand.[/face]