Weird behavior of the %S and %R command line parameters

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
iG0R
Junior Member
Junior Member
Posts: 58
Joined: 2018-10-05, 16:16 UTC

Weird behavior of the %S and %R command line parameters

Post by *iG0R »

Hi.
As the title says, I've run into this issue.
I am trying to integrate WinMerge into TC according to the following task:
WinMerge has to compare only selected files in whatever panel (left or right) these selected files are located.
I will monitor the quantity myself to ensure that they do not exceed 3.
According to the documentation, the %S parameter should specifically only apply to selected files, i.e. files simply under the cursor should not fall under its effect.
%S insert the names of all selected files into the command line. Names containing spaces will be surrounded by double quotes. Please note the maximum command line length of 32767 characters.
So, at the beginning, according to the documentation:
%P%S insert the names of all selected files into the command line, with full path. Names containing spaces will be surrounded by double quotes. Do NOT put quotes around %P%S yourself!
I tried the following command line parameters for WinMerge:

Code: Select all

/u %P%S
But it didn't work. With this parameter, only the selected files of the active panel are transferred.
OK. I tried another parameters with the additional %R parameter
%R like %S, but with selected names from the target panel

Code: Select all

/u %P%S %P%R
It didn't work either, as the path for all files turn out to be dependent on the active panel.
OK. I tried another approach with the %T parameter
%T inserts the current target path. Especially useful for packers.

Code: Select all

/u %P%S %T%R
Yes, finally, it works!
BUT, if I want to compare selected files only from one panel (left or right) - it doesn't work as it should be.
Even if there are no selected files in one of the two panels, when I try to compare the selected files, somehow inexplicably the command line that is passed to WinMerge includes a file from the panel that had no selected files, but last time it was or is now under the cursor.
Can anyone explain why this is happening, and is there any way to accomplish the task mentioned at the beginning of my post?
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6969
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Weird behavior of the %S and %R command line parameters

Post by *Horst.Epp »

Use a Button like this one (Adapt the path)

Code: Select all

TOTALCMD#BAR#DATA
C:\Tools\WinMerge\WinMergeU.exe
%C1 %C2
C:\Tools\WinMerge\WinMergeU.exe
WinMerge

0
-1
Windows 11 Home, Version 24H2 (OS Build 26100.3915)
TC 11.55 RC1 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.2.1 x64
iG0R
Junior Member
Junior Member
Posts: 58
Joined: 2018-10-05, 16:16 UTC

Re: Weird behavior of the %S and %R command line parameters

Post by *iG0R »

Thank you for your reply.
Unfortunately, it doesn't work the way it should.
WinMerge can compare 3 files.
Even if I change the button this way:

Code: Select all

TOTALCMD#BAR#DATA
"F:\WinMerge\WinMergeU.exe"
/u %C1 %C2 %C3
"F:\WinMerge\WinMergeU.exe"
WinMerge
"F:\WinMerge\"

-1
When I select 3 files only in one panel, this approach works well - 3 files open in WinMerge, but when I select 1 file in one panel and 2 files in another - only 2 files open, one from each panel.
User avatar
petermad
Power Member
Power Member
Posts: 16027
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Weird behavior of the %S and %R command line parameters

Post by *petermad »

iG0R wrote: 2023-11-05, 04:06 UTC

Code: Select all

/u %P%S %T%R
Yes, finally, it works!
BUT, if I want to compare selected files only from one panel (left or right) - it doesn't work as it should be.
Even if there are no selected files in one of the two panels, when I try to compare the selected files, somehow inexplicably the command line that is passed to WinMerge includes a file from the panel that had no selected files, but last time it was or is now under the cursor.
Can anyone explain why this is happening, and is there any way to accomplish the task mentioned at the beginning of my post?
You can use %Y to have nothing passed if there are no selected files.
Help wrote:%Y anywhere in the parameters: Pass empty list to program when nothing is selected when using one of the List parameters like %L, or multi-file parameters like %S. Otherwise, the file under the cursor would be passed.
So use:

Code: Select all

/u %Y %P%S %T%R
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Fla$her
Power Member
Power Member
Posts: 2996
Joined: 2020-01-18, 04:03 UTC

Re: Weird behavior of the %S and %R command line parameters

Post by *Fla$her »

petermad wrote: 2023-11-05, 13:06 UTC So use:

Code: Select all

/u %Y %P%S %T%R
Why are you putting an extra space next to %Y?
Overquoting is evil! 👎
iG0R
Junior Member
Junior Member
Posts: 58
Joined: 2018-10-05, 16:16 UTC

Re: Weird behavior of the %S and %R command line parameters

Post by *iG0R »

2petermad
Thanks a lot!
Finally, it works.
Just in case, maybe someone will need a button with the same functionality:

Code: Select all

TOTALCMD#BAR#DATA
"F:\WinMerge\WinMergeU.exe"
/u %Y %X%P%S %X%T%R
F:\WinMerge\WinMergeU.exe

F:\WinMerge\

-1
User avatar
petermad
Power Member
Power Member
Posts: 16027
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Weird behavior of the %S and %R command line parameters

Post by *petermad »

Fla$her wrote:Why are you putting an extra space next to %Y?
Because I feel like it.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Fla$her
Power Member
Power Member
Posts: 2996
Joined: 2020-01-18, 04:03 UTC

Re: Weird behavior of the %S and %R command line parameters

Post by *Fla$her »

2petermad
Do you like extra characters in the command line? The case, of course, is yours, but let the user know that this is not necessary. 👆
Overquoting is evil! 👎
iG0R
Junior Member
Junior Member
Posts: 58
Joined: 2018-10-05, 16:16 UTC

Re: Weird behavior of the %S and %R command line parameters

Post by *iG0R »

2Fla$her
One extra character is evil :D
IMHO, with an extra space it becomes, say, more readable.
Fla$her
Power Member
Power Member
Posts: 2996
Joined: 2020-01-18, 04:03 UTC

Re: Weird behavior of the %S and %R command line parameters

Post by *Fla$her »

iG0R wrote: 2023-11-06, 09:09 UTC IMHO, with an extra space it becomes, say, more readable.
Such readability means nothing to me. You either know what each parameter is responsible for, or you don't. The button is formed not to read the settings later, but to use.
You might as well do it with the %X parameter: /u %X %Y %P%S %T%R (it doesn't need to be specified twice). 🙃
Overquoting is evil! 👎
iG0R
Junior Member
Junior Member
Posts: 58
Joined: 2018-10-05, 16:16 UTC

Re: Weird behavior of the %S and %R command line parameters

Post by *iG0R »

2Fla$her
Thanks a lot.
Your version is also very convenient for understanding.
Post Reply