Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

@File List and SELECT acting weird

Apr
4
0
Code:
DIR /B /A:d %TYPE%\*%2* > D:\TEMP\LIST.TXT
SELECT /O:u GOSUB LAUNCH %TYPE (@D:\TEMP\LIST.TXT)

I am in the process of writing a batch file and I have the above two lines as a part of it. The select line does not seem to be operating as expected. I've been unable to find out if I've got a simple typo that I'm not seeing or if this is a bug in TCC26 (the version I'm on currently).

Prior to this code %TYPE is set to one of two sub-directories in full path format starting with the drive letter, which in both cases is Z:\. There is no white space in %TYPE requiring quoting. The second argument to the batch file is to be a search term for a sub-directory within %TYPE. The first line creates D:\TEMP\LIST.TXT which contains all sub-directories within %TYPE that match the search term. In reviewing the file, it is the full path format of the found sub-directories. There are no quotes around these paths. In my case most of them have white space in the final level directory, or the found part.

The second line enters the select screen with the sub-directories in LIST.TXT as options to select. They are listed without their path. After selecting the particular sub-directories wanted, this passes the first argument the value of %TYPE to the subroutine LAUNCH. I would expect that the second argument passed would be one of the selected sub-directories with out their path. If, for example, I were to select the sub-directory DOE, James (123-456-789), I would expect that to be the second argument passed to LAUNCH. However, I am getting "@D:\TEMP\DOE, James (123-456-789)" with the quotes. It is like the contents within the brackets in the second line are passed after replacing LIST.TXT with the name of the selected sub-directory and putting the whole thing within quotes.

I need to give the full path of LIST.TXT because the batch file is being run with the current directory down the tree on W:\ and once deployed will be on C:\ in a directory to which the user running it will not have write priveledges. I cannot use simply the current directory in this unless I do a PUSHD/POPD to change to D:\TEMP for part of the duration of the batch file's execution.
 
You're using the wrong SELECT. The SELECT command will always create a full pathname for the filename arguments you select.

I believe what you really want to use is the @SELECT variable function, which simply returns the lines you selected and doesn't assume that the arguments are filenames to be expanded.
 
I have taken a look at the @SELECT function and it does seem like it would work except for the fact that it only allows selecting one item. With the SELECT command, more than one item can be marked as selected and then the command works in series on each of the selected items. I was looking for that functionality.

After testing a few scenarios, I have found a simplified way of doing this by adding the /A:d switch to the SELECT command, replacing the contents of the parenthesis with %TYPE%\%2, and getting rid of the DIR command. No need for the file that the DIR is redirected to and the SELECT was supposed to use.

Thanks for the help, I can add @SELECT to the toolkit of elements I'm familiar with now. I have been using the software and its predecessors since the late 80s or early 90s when 4DOS was featured in Compute!'s PC Magazine.
 
Back
Top
[FOX] Ultimate Translator
Translate