Standalone and modified %WL-like list file inconsistency in some cases.

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
beb
Power Member
Power Member
Posts: 579
Joined: 2009-09-20, 08:03 UTC
Location: Odesa, Ukraine

Standalone and modified %WL-like list file inconsistency in some cases.

Post by *beb »

Comparison:
# %WL standalone %WL with modifier
% modifier not applicable %Y
modebehaviorbehavior
1no selection,
cursor on [..]
nothing = useless:
no valid %WL parameter,
no list file,
no other valid parameters are passed as well
fully useful:
%WL parameter is valid,
list file is empty,
other parameters: OK
(e.g., %P, %T, etc, are passed)
2 no selection,
cursor on a file/folder
fully useful:
item under cursor is passed to %WL,
list file is a list,
other parameters: OK
effectively useless:
item under cursor is NOT passed to %WL,
list file is empty,
other parameters: OK
3 active selection,
there are files/folders selected
fully useful:
all selected items are passed to %WL,
list file is a list,
other parameters: OK
fully useful:
all selected items are passed to %WL,
list file is a list,
other parameters: OK


Question(s):

Can we have the standalone list file parameter ('%WL') and the modified list file parameter ('%WL %Y') behaviour consistent regarding point 2?
I.e., when there's no selection and the cursor is on a file/folder, the item under the cursor is sent to the list file.

If not, then can we have a separate modifier for '%WL' that would keep points 1,3 useful behavior as of '%WL %Y' and obtain point 2 useful behavior as from standalone '%WL'?

What exactly is being caught there from the TC in case 1 [in place of %WL or rather by itself?
As I can see, it is assumed to be just the current active pane path.]* It can easily be seen as such and would work like a charm most of the time (for regular situations).
However, if the active path happens to exceed the 260-symbol limitation, only the drive letter is passed/accepted, and the logic to further work with files and folders (as in the example script below) would completely fail.
Can the TC handle the super-long paths here?

* Note: I'm not sure what the correct wording for that to be there, sorry.

Tools for testing, if needed:

PowerShell script (echoParamsFiles.ps1):

Code: Select all

$time = [diagnostics.stopwatch]::StartNew()
$files = $folders = @()
if ($pwd){
'try current path as $pwd'|Write-Host -f DarkCyan
$pwd|Write-Host -f Cyan
$path = [string]$pwd;$length=$path.length+1}
''
if (-not($args)){$message = 'working folder ($pwd)'
'no parameters; try files from current path'|Write-Host -f DarkCyan
$files = Get-ChildItem $path -file -recurse -force
$folders = Get-ChildItem $path -directory -recurse -force}

if ($args){$message = '%WL list file'
'list file as %WL'|Write-Host -f DarkCyan
$list = [IO.FileInfo]$args[0];$list.Name|Write-Host -f Cyan
''
'source path as %P'|Write-Host -f DarkCyan
$source = [IO.DirectoryInfo]$args[1];$source.Name|Write-Host -f Cyan
$path = [string]$source;$length=$path.length
''
'target path as %T'|Write-Host -f DarkCyan
$target = [IO.DirectoryInfo]$args[2];$target.Name|Write-Host -f Cyan
''
'read %WL list file ({0})' -f $list.Name|Write-Host -f Green
if ($list.length -le 2){'list file is empty'|Write-Host -f Yellow} else {
$lines = [IO.File]::ReadLines($list)
foreach ($line in $lines){
if ((Get-Item $line) -is [IO.FileInfo]){
$file = [IO.FileInfo]$line;$files += $file}
if ((Get-Item $line) -is [IO.DirectoryInfo]){
$folder = [IO.DirectoryInfo]$line;$folders += $folder}}}}
''
# do something with files and folders
'{0} files in {1}' -f $files.count,$message|Write-Host -f DarkCyan
foreach ($file in $files){
# do something with files (here, display relative paths)
$file.FullName.substring($length)|Write-Host -f Cyan}
''
'{0} folders in {1}' -f $folders.count,$message|Write-Host -f DarkCyan
foreach ($folder in $folders){
# do something with folders (here, display relative paths)
$folder.FullName.substring($length)|Write-Host -f Cyan}
''
$time.Stop()
'{0} files and {1} folders found for {2:mm}:{2:ss}.{2:fff}' -f $files.count,$folders.count,$time.Elapsed|Write-Host -f DarkCyan
sleep -seconds 12
user-commands (usercmd.ini):

Code: Select all

[em_test_tc_params_files]
cmd=pwsh -c "%commander_path%\Plugins\apps\PowerShell\echoParamsFiles.ps1"
param=%WL '%P' '%T' %Q %Y
[em_test_tc_params_files_standalone]
cmd=pwsh -c "%commander_path%\Plugins\apps\PowerShell\echoParamsFiles.ps1"
param=%WL '%P' '%T' %Q
user-buttons:

Code: Select all

TOTALCMD#BAR#DATA
em_test_tc_params_files

wcmicon2.dll


0
-1

Code: Select all

TOTALCMD#BAR#DATA
em_test_tc_params_files_standalone

wcmicons.dll


0
-1
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10/15
Fla$her
Power Member
Power Member
Posts: 2981
Joined: 2020-01-18, 04:03 UTC

Re: Standalone and modified %WL-like list file inconsistency in some cases.

Post by *Fla$her »

beb wrote: 2025-04-24, 08:59 UTC I'm not sure what the correct wording for that to be there, sorry.
Yes, the descriptions for point 2 contradict logic. If files are not marked, the file under the cursor is considered selected. Therefore, it is incorrect to write "no selection" + "cursor on a file/folder" + "item under cursor is ...".
I.e., when there's no selection and the cursor is on a file/folder, the item under the cursor is sent to the list file.
This happens without %Y, according to the description. What's wrong?

Actually, it doesn't make sense to separate all the modifier parameters with spaces. Why are you doing this?
What exactly is being caught there from the TC in case 1 [in place of %WL or rather by itself?
The question is unclear.
However, if the active path happens to exceed the 260-symbol limitation, only the drive letter is passed/accepted, and the logic to further work with files and folders (as in the example script below) would completely fail.
Where? %P returns the entire path, with 260+ characters.

PS: I don't have time to analyze the powershell code, sorry.
Overquoting is evil! 👎
User avatar
petermad
Power Member
Power Member
Posts: 15997
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Standalone and modified %WL-like list file inconsistency in some cases.

Post by *petermad »

2beb

Notice that there is a difference between using %Y and %y:
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.

%y anywhere in the parameters: When nothing is selected when using one of the List parameters like %L, pass all other parameters except for the list parameter to the called program.
Note: %Y%y works like %y when something is selected or the cursor stands on "..", otherwise it selects the file under the cursor
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
Post Reply