SELECTFILES range does not work correctly with equal sign

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
Gral
Power Member
Power Member
Posts: 1467
Joined: 2005-01-26, 15:12 UTC

SELECTFILES range does not work correctly with equal sign

Post by *Gral »

SELECTFILES with range e.g.

Code: Select all

cmd=SELECTFILES
param="%S:~0,20*.*"
does not work correctly - selects all files instead - if the range contains an equal sign.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48077
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: SELECTFILES range does not work correctly with equal sign

Post by *ghisler(Author) »

Sorry, I don't understand your report.
1. I don't see any equal sign in your parameters
2. That *.* is wrong, it will not be appended to each file in%S, only once at the end, e.g.
filename1 filename2 filename3*.*
Author of Total Commander
https://www.ghisler.com
User avatar
Gral
Power Member
Power Member
Posts: 1467
Joined: 2005-01-26, 15:12 UTC

Re: SELECTFILES range does not work correctly with equal sign

Post by *Gral »

Sorry i've tried extremely short report.

Now i don't understand what you mean by "appended"?
It is not for send filenames to any program, it's for SELECT files with names similar to file under cursor, here identical first 20 chars, so without *.* or * it try to select files with exactly 20 identical and only 20 chars in names .
What do you think - how many such a files exist in 1 directory?

As i wrote it's works perfectly with parameters

"%S:~0,20*.*"

or

"%S:~0,20*"

and select all files with identical 20 first chars unless "=" is one of them

My real command for button is

Code: Select all

[em_SelectFilesBase020]
button=WCMICON2.DLL,44
cmd=SELECTFILES
param="%S:~0,20*"
Testing set of names

Code: Select all

00000000001111111111=00001
00000000001111111111=00002
00000000001111111111=00003
11111222223333344444=00011
11111222223333344444=00012
11111222223333344444=00013
16498627147510674302349097
42637578038286926476213523
73503319593530159480536009
(just create empty files using FSUTIL)

Note "=" in names on 21 position, with "%S:~0,20*" or "%S:~0,20*.*" and set cursor on first file and chose command by click on button - it works - select first 3 files.
Now move = to 20 position e.g. search & replace "1=" to "=1" in MRT, and it doesn't works anymore - select ALL files!
Now replace = with + (or # or $ or @ or any sign allowed in filenames) - it works again!

So equal sign, designed to autorun sometimes such a command is problem here.
It is not new bug - exist in TC 10.52
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48077
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: SELECTFILES range does not work correctly with equal sign

Post by *ghisler(Author) »

I'm not quite sure what you are trying to do. Do you understand that %S inserts the names of all selected files? And do you understand that *.* is appended only to the LAST of these names? Also that it's added behind the quote, e.g. "last of the names"*.* ? So your parameter doesn't really make any sense.
Author of Total Commander
https://www.ghisler.com
User avatar
Gral
Power Member
Power Member
Posts: 1467
Joined: 2005-01-26, 15:12 UTC

Re: SELECTFILES range does not work correctly with equal sign

Post by *Gral »

So what SELECTFILES do?
Have you tried what I described?

OK, it seems works correctly with "%N:~0,20*" instead but it still very strange how it works or not with "%S:~0,20*" depends on equal sign.
If nothing selected and cursor is set on file behaviour %N and %S shouldn't be identical?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48077
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: SELECTFILES range does not work correctly with equal sign

Post by *ghisler(Author) »

TC puts names with spaces in double quotes, as well as names with equal signs in them (and no spaces). That's why you see a difference when there is an equal sign in the name.

Just put a question mark "?" as the first character of the parameters to see how TC uses the placeholders.
Author of Total Commander
https://www.ghisler.com
User avatar
Gral
Power Member
Power Member
Posts: 1467
Joined: 2005-01-26, 15:12 UTC

Re: SELECTFILES range does not work correctly with equal sign

Post by *Gral »

I know how use question mark for test parameters, although i didn't test earlier this command

So now i tested it and i see how it works here:
with double quotes it works as it should - "*.*" is appended at the end of every file!
without double quotes is appended once at the end of whole string

And now worst part - it's works different way with and without "?"
With "?" at start my expression works fully as expected - when i select one file from each of first 2 groups, after call command i see dialog window and after press OK whole 2 groups are selected
when i start command directly without "?" it's works different way - select all files.

So here is a new bug - question mark changes parameters sended to command.

My current testing set of filenames

Code: Select all

00000000001111111111 00001
00000000001111111111 00002
00000000001111111111 00003

1111122222333334444=400011
1111122222333334444=400012
1111122222333334444=400013

16498627147510674302349097
42637578038286926476213523
73503319593530159480536009
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48077
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: SELECTFILES range does not work correctly with equal sign

Post by *ghisler(Author) »

I will check it, thanks. It makes no sense at all to get different behaviour with and without ? at start.
Author of Total Commander
https://www.ghisler.com
User avatar
Gral
Power Member
Power Member
Posts: 1467
Joined: 2005-01-26, 15:12 UTC

Re: SELECTFILES range does not work correctly with equal sign

Post by *Gral »

That's it. IMO, the correct and expected behavior is that with the question mark - selecting entire groups when at least one file from the appropriate group is selected.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48077
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: SELECTFILES range does not work correctly with equal sign

Post by *ghisler(Author) »

I have checked that - the reason is a rather strange behaviour of the Windows ini file functions: When you read a string from the ini file, and the string is enclosed in double quotes, then Windows removes those double quotes. Example:
param="%S:~0,20*.*"
is read as %S:~0,20*.*
param=?"%S:~0,20*.*"
is read as ?"%S:~0,20*.*"

When you configure the button via dialog, TC adds an extra pair of double quotes in this case to avoid the issue:
param=""%S:~0,20*.*""
When editing the .bar file yourself, you need to do that manually.
Author of Total Commander
https://www.ghisler.com
Post Reply