F4 doesn't pass long names under some circumstances

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
serjayes
Junior Member
Junior Member
Posts: 56
Joined: 2004-01-19, 16:53 UTC

F4 doesn't pass long names under some circumstances

Post by *serjayes »

I want to associate the F4 with my own script which would decide what to start. E.g. if the extension is .xls just start it, if it's .cpp open the programming editor if it's unknown and small open notepad if it's big just open the lister (this protects from trying to open too big file).

And I'd like not to get 8.3 names. I have found this in old history of TC: "24.02.97 Added: F4 will now pass the long name to the editor if the editor is a 32-bit program (only if full path to editor given)"

So I try to get the long name passed from TC to the script. And I see I need the full path. Still, if I specify the script in "Editor for F4" as:

Code: Select all

c:\windows\system32\wscript.exe C:\util\q.js
and I get the 8.3 name passed to q.js when I press F4 on the file in My Documents:

Code: Select all

C:\DOCUME~1\MUSTER~1\MYDOCU~1\SHORT.EXT
If there's still the need to pass short names at all, then TC should (during the processing of the entered F4 editor string) recognize where the executable name is and where the parameters to the executable are. I believe at the moment it tries to find everything together, doesn't find that what he believes is file (although it's a file and a parameter) and decides "I'll do 8.3"

Note also that the executable name can be inside of " " when the spaces are part of the path. Stil,l the parameters should be able to follow the executable. Even without scripts, any program with parameter would at the moment get short names.

If you ask why I can't just enter c:\util\q.js as association: 1) script engines typically have two flavours -- one for starting scripts from gui apps and another for the one from command line environment (in this case cscript and wscript), and I have the the "command line" as active association, but I need here gui one to avoid the display of command window 2) even if I'd associate the wscript to js I'd still get the 8.3 name with the current TC.

To conclude: I believe there is a bug in processing of F4 string, where parameters are treated as the part of the name of executable.

Thank you.

P.S. The example script is:

Code: Select all

function getStart()
{
    if ( s.match( /\.xls$/i ) )
        return ''
    return ( fso.GetFile( s ).size < 500e3 )
        ? "notepad ": "lister "
}

sh = WScript.CreateObject( "WScript.Shell" )
fso = WScript.CreateObject( "Scripting.FileSystemObject" )
s = WScript.Arguments( 0 )

var cmd = getStart() + '"' + s + '"'
// WScript.Echo( s );
sh.Run( cmd, 1, false )
You can uncomment Echo line to see that 8.3 names are passed.
(user licence #64081)
User avatar
sqa_wizard
Power Member
Power Member
Posts: 3864
Joined: 2003-02-06, 11:41 UTC
Location: Germany

Post by *sqa_wizard »

What about adding a "%1" like mentioned here ?

Code: Select all

c:\windows\system32\wscript.exe C:\util\q.js "%1"
#5767 Personal license
serjayes
Junior Member
Junior Member
Posts: 56
Joined: 2004-01-19, 16:53 UTC

Post by *serjayes »

sqa_wizard, thank you, it works!
(user licence #64081)
User avatar
sqa_wizard
Power Member
Power Member
Posts: 3864
Joined: 2003-02-06, 11:41 UTC
Location: Germany

Post by *sqa_wizard »

sqa_wizard, thank you, it works!
:D Thanks for the feedback.

I just searched the forum for "short name editor" and it was the 4th hit incl. yours :)

Most of the reported problems are solved already ... you may do a search first next time. 8)
#5767 Personal license
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48093
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Indeed TC calls a Windows function here to find out whether the editor is 32-bit or not. If not, or if the Windows function fails (here: because of the extra parameters), TC will pass the 8.3 name because that always works. Using "%1" including the double quotes explicitly tells TC to pass the long name.
Author of Total Commander
https://www.ghisler.com
Post Reply