File: XTree:\Forum archive |Bottom_of_page

| View Thread | Return to Index | Read Prev Msg | Read Next Msg |

XTree Forum archive

Re: Batch "parameters" (and a PROPOSAL)

Posted By: Walter Rassbach <>
Date: Monday, 14 September 1998, at 7:58 a.m.

In Response To: Re: Configured "Command" keys - PROPOSAL PART 1 (Martin J. van Groen)

With regard to the batch parameter parts of Martin's posting, I did a little playing around with some .BAT files (I give them at the end...), and have a couple of handling suggestions for those people who have not dealt with these kinds of issues before... I also make a proposal for some enhancements near the end of this posting (just above the .BAT file listings).

First, as I expected, Kim does pass the parameters associated with long file names (LFNs) correctly surrounded by double quotes (I think I remember a few fixes that he had in the beta pages getting it right...). What I had not remembered is that the parameter value accessible in the .BAT file STILL HAS THE DOUBLE QUOTES as the first and last characters... In other words, the command line parsing for .BAT files does recognize double quotes correctly but does not strip them from the parameter.

Second, I don't think that there is anyway that Kim can change the meaning or order of any of the currently assigned batch parameters, too many things would get broken... Also, in fact, I think he DID make the right choices (in most places, not just this one, although I also have my pet few...) in moving the design from the 8.3 DOS XTree to the LFN W95/NT ZTree. There was no way that the tradeoffs he had to make would work in every situation, something was gonna bust either way on some of the choices he had to make... In the area of the batch parameters, he went with semantic content (which seems right to me) and added some parameters to try to cover the other cases...

The current "batch" parameter set is as follows:

%0 The batch program name itself (e.g., D:\ZTW\TXT.BAT) [some people may not have know this.
.. This parameter is not available in the ctrl-/alt-"B"atch commands (ought to be ZTree, e.g., D:\ZTW\ZTW.EXE, or something similar and useful)

%1 The full LFN drive, path and file name of the selected item, with all capitalization preserved (e.g., if one file has an extension of ".trick" and another uses ".TrIcK", the same TRICK.BAT is called by Open but the case is preserved in the LFN-style parameters) and surrounded by double quotes where necessary WHICH ARE PRESERVED/PRESENT IN THE PARAMETER (there are a few places where I know Kim and I disagree about the need for quotes, but that's a MUCH more esoteric issue...)

%2 Drive letter (always upper case I believe...), no colon, no quotes.

%3 The LFN path, no drive letter or colon, leading '\', no trailing '\', double quoted if necessary, case preserved.

%4 The LFN filename with the rightmost period and extension stripped (i.e., the "main" part of the name), case preserved, quoted if necessary. This name may still contain a period if the original filename contained multiple periods (e.g., for a file named "this.one.trick" it is "this.one"), but it may or may not be quoted (in the example it won't be) -- This is VERY nice when dealing with some of Windows default .LNK/.PIF file conventions.

%5 The LFN extension, no leading period, case PRESERVED, double quoted if necessary (e.g., if there is a space in the extension part)

%6 The LFN name of the directory containing the subject file, case preserved, not '\' characters, quoted if necessary. (e.g., for a full path/file like "C:\AB\CD\X y\pqr.xyz" this parameter would be, WITH the quotes: "X y"). NOTE: This is what shows up in the parameter of a batch file invoked via Open, and I believe this is also true for the alt-/ctrl-"B"atch commands in ZTree -- KIM: the ZTree help file appears to be incorrect here...

%7 The 8.3 equivalent of %1, i.e., the "short form" drive, path, and filename and extension. This is never quoted, is always all uppercase, and will never contain any spaces (they get compressed out of both directory and file names).

%8 The short form filename with no periods or extension part. Always all uppercase. This parameter is currently ONLY AVAILABLE in an alt-/ctrl-"B"atch command, not in the parameters passed to a .BAT invoked via the Open command.

PARAMETER HANDLING: Because the LFN version parameters are double quoted where necessary (e.g., if they contain spaces), AND, the quotes themselves are part of the parameter, they can be passed on to further batch files in the normal way (DON'T ADD additional quotes -- my other posting here was incorrect on that point). Martin: Hopefully this handling information may be helpful in dealing with at least part of your problems...

ADDITIONAL NOTE: When you use the "O"pen command on a file, ZTree looks for a file with the name ext.BAT in your ZTree folder. The "ext" used is the LFN extension, NOT the short name extension (possibly it should look for both, but...), The case is ignored, i.e., TRICK,BAT is invoked for any of xyz.trick, tstfile.TrIcK, or nother.tRICk, and AN EXT,BAT is invoked for "a.an ext", "a file.AN ext", etc.), but a file with any of those extensions will not find either TRI,BAT or ANE.BAT (the short forms of the two extensions...). If it finds one, it is called and otherwise ZTree passes the file on to the Windows API open function (thereby getting you to Word or whatever...)

=======================================================================
PROPOSAL: I would like to propose the following enhancements:

1) Provide the %8 parameter to the .BAT files invoked via Open
2) Add a %9 parameter which contains the short form extension (like %5) or the short form path (like %3). My preference is the extension, and the other would be available from item (3).
3) Provide the short form path (or the extension, depending on (9)) as %10. Although this one is not directly accessible, SEE BELOW.
4) Provide the short form versions of the other parameters (remember to duplicate the drive letter too!) as %11, %12, etc. SEE BELOW.

The %10, %11, etc. parameters are NOT directly available in the .BAT file, but CAN BE ACCESSED through the use of a "SHIFT" command in the actual .BAT file invoked by Open. The batch-file SHIFT command discards %0 and shifts the other parameters down "one digit", so %0 becomes the old %1, %1 becomes the old %2, etc. Since the original %0 is not especially useful (I use it on occasion, but most people never have), the first SHIFT doesn't really cause any meaningful information to be lost and makes item (3) accessible... The full short form drive, path, and file/ext name can then be constructed as %1:%9\%7.%8 (I think that is right, but don't hold me to it -- there may be some cases where it doesn't work, like in the root directory...). The other parameters can be reached by further SHIFT's, but those SHIFT's are now going to "throw away" possibly meaningful/useful information (this is why the drive letter should be duplicated since it gets thrown away early...).

The above is at least a functional solution to some of the problems Martin's posting identifies, at least in the .BAT files invoked via the Open command.
For ZTree's alt-/ctrl-"B"tch commands, we (or Kim) would have to come up with something slightly different since there is no SHIFT available. However, in this case, ZTree is doing the substitutions and can extend things to perform substitions on (for example) either %10, %11, etc. or on %A, %B, etc. I don't have a particular preference here (I'm used to hexadecimal notation).

IF ANYONE OUT THERE HAS A STRONG PREFERENCE regarding either the method used for alt-/ctrl-"B"atch or what should be provided as %9, %10, etc, GET YOUR VOTE IN in a posting here (and SOON)...

I'm not sure how the substitution is done in the Menu system within ZTree since I don't use it much, but I'm sure that something workable can be implemented...

-- Walter
========================================================================
The .BAT files I used to check out the parameters should be placed in your ZTree folder, and then a test directory structure and set of filenames placed somewhere (with things like LFH directories, filenames with things like periods and spaces in them, appropriate extensions, etc.):

TST.BAT is
@echo For TST, have:
@echo "%0"
@echo "%1"
@echo "%2"
@echo "%3"
@echo "%4"
@echo "%5"
@echo "%6"
@echo "%7"
@echo "%8"
@echo "%9"
@pause

TRICK,BAT is
@echo For TRICK, have:
@echo "%0"
@echo "%1"
@echo "%2"
@echo "%3"
@echo "%4"
@echo "%5"
@echo "%6"
@echo "%7"
@echo "%8"
@echo "%9"
@pause
@echo Now, TST with quotes
@call d:\ztw\TST "%1" "%2" "%3" "%4" "%5" "%6" "%7" "%8" "%9"
@pause
@echo Now, TST without quotes
@call d:\ztw\TST %1 %2 %3 %4 %5 %6 %7 %8 %9
@pause

AN EXT.BAT is (this one is to check extensions with spaces and SHIFT...)
@echo For AN EXT, have:
@echo "%0"
@echo "%1"
@echo "%2"
@echo "%3"
@echo "%4"
@echo "%5"
@echo "%6"
@echo "%7"
@echo "%8"
@echo "%9"
@pause
SHIFT
@echo "%0"
@echo "%1"
@echo "%2"
@echo "%3"
@echo "%4"
@echo "%5"
@echo "%6"
@echo "%7"
@echo "%8"
@echo "%9"
@pause

Messages in This Thread

| View Thread | Return to Index | Read Prev Msg | Read Next Msg |

XTree Forum archive is maintained by Mathias Winkler with WebBBS 3.21.

 
---<>---
 
Xtree and XtreeGold are registered trademarks of Symantec Inc.
Other brands and products are trademarks of their respective holders.


FILE COMMANDS:  Directory_view Previous_file   Next_file cuRrent   /Help |Top_of_page