Passing parameters to a program

English support forum

Moderators: Hacker, petermad, Stefan2, white

User avatar
robinsiebler
Senior Member
Senior Member
Posts: 460
Joined: 2003-03-05, 21:04 UTC

Passing parameters to a program

Post by *robinsiebler »

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?
User avatar
lzvk25
Member
Member
Posts: 183
Joined: 2003-02-09, 04:28 UTC
Location: Collierville, TN

Post by *lzvk25 »

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 ?
:?
Memo to Boss : No TC, No Work
User avatar
piranha
Junior Member
Junior Member
Posts: 70
Joined: 2003-02-07, 19:55 UTC
Location: Miami, Fl
Contact:

Re: Passing parameters to a program

Post by *piranha »

robinsiebler 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?
I guess you'd have to select them in source and target window (one file per window) and use like %P and %M
Afaik TC cannot pass names of selected files to command line (except %L).
User avatar
JackFoo
Senior Member
Senior Member
Posts: 373
Joined: 2003-02-05, 19:53 UTC
Location: ERROR

Post by *JackFoo »

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.
User avatar
robinsiebler
Senior Member
Senior Member
Posts: 460
Joined: 2003-03-05, 21:04 UTC

That worked!

Post by *robinsiebler »

Thanks!
User avatar
Valentino
Power Member
Power Member
Posts: 709
Joined: 2003-02-07, 00:21 UTC
Location: Ukraine

lst2str enhancement

Post by *Valentino »

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 :(.
User avatar
JackFoo
Senior Member
Senior Member
Posts: 373
Joined: 2003-02-05, 19:53 UTC
Location: ERROR

Post by *JackFoo »

@Valentino
I'll try to improve it, but it'll take some time, around a week (depends on the load of work and studies I'll have). I don't usually program for windows (more to do with algorithms and such) so it'll remain a console app.

Cheers.
User avatar
Hacker
Moderator
Moderator
Posts: 13141
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

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
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.
User avatar
Valentino
Power Member
Power Member
Posts: 709
Joined: 2003-02-07, 00:21 UTC
Location: Ukraine

Post by *Valentino »

2Hacker
No problem. What colors do you see the best? List several ones so I could choose the best for my template also.
JackFoo wrote:I don't usually program for windows (more to do with algorithms and such) so it'll remain a console app.
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.
User avatar
JackFoo
Senior Member
Senior Member
Posts: 373
Joined: 2003-02-05, 19:53 UTC
Location: ERROR

Post by *JackFoo »

Sure you can do it if you wish no hard feelings.

P.S.
Just made a new version, but you can write another if you want, I don't mind the console.

Cheers.
User avatar
Black Dog
Power Member
Power Member
Posts: 1024
Joined: 2003-02-05, 22:17 UTC
Location: Odessa
Contact:

Post by *Black Dog »

[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]
User avatar
Hacker
Moderator
Moderator
Posts: 13141
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Valentino.
Well, red, orange, yellow, green, cyan, violet and white. White rulez.


Black Dog,
:( Why?

TIA
Roman
User avatar
Black Dog
Power Member
Power Member
Posts: 1024
Joined: 2003-02-05, 22:17 UTC
Location: Odessa
Contact:

Post by *Black Dog »

[face=courier]On 07-03-2003 13:14:02 +0000 Hacker wrote:

H> Black Dog,
H> :( Why?


I like maroon ;).[/face]
User avatar
Valentino
Power Member
Power Member
Posts: 709
Joined: 2003-02-07, 00:21 UTC
Location: Ukraine

Post by *Valentino »

Hacker wrote:Well, red, orange, yellow, green, cyan, violet and white. White rulez.
Green, red, orange and violet are visible on default template. Others not. So I'll try to use one of them in future (if I won't forget). :)
TucknDar
Senior Member
Senior Member
Posts: 227
Joined: 2003-02-07, 09:44 UTC
Location: Oslo
Contact:

Post by *TucknDar »

Black Dog: why do you always use another font than the rest? I find it slightly annoying...
license #76904
Post Reply