- Nov
- 344
- 10
I defined a new function, to tell if a given drive is a substituted one or not (following a tip given here a while ago). This function:
function substituted=`%@if["%@left[2,%@truename[%1]]"=="%1",0,1]`
works on ready drives, but fails on non-existing ones (the drives marked with an asterisk are substitutions):
[C:\Users\Miguel\TCC]pwd
NEGRO1 C:\Users\Miguel\TCC\
BLACK2 D:\
NEGRO1 *F:\
NEGRO1 *S:\
NEGRO1 *T:\
[C:\Users\Miguel\TCC]echo %@substituted[C:]
0
[C:\Users\Miguel\TCC]echo %@substituted[T:]
1
[C:\Users\Miguel\TCC]echo %@substituted[X:]
TCC: (Sys) The system cannot find the drive specified.
"X:"
I tried to improve it by prepending a %@ready call, but it didn't work:
[C:\Users\Miguel\TCC]function substituted2=`%@if["%@ready[%1]"=="1" .and. "%@left[2,%@truename[%1]]"=="%1",0,1]`
[C:\Users\Miguel\TCC]echo %@substituted2[C:]
0
[C:\Users\Miguel\TCC]echo %@substituted2[T:]
1
[C:\Users\Miguel\TCC]echo %@substituted2[X:]
TCC: (Sys) The system cannot find the drive specified.
"X:"
I tried to nest to %@if calls instead:
[C:\Users\Miguel\TCC]function substituted3=`%@if["%@ready[%1]"=="1",%@if["%@left[2,%@truename[%1]]"=="%1",0,1],2]`
[C:\Users\Miguel\TCC]echo %@substituted3[C:]
0
[C:\Users\Miguel\TCC]echo %@substituted3[T:]
1
[C:\Users\Miguel\TCC]echo %@substituted3[X:]
TCC: (Sys) The system cannot find the drive specified.
"X:"
... and it doesn't work either.
The help page for @if states "Do not use @IF if evaluating either one of the strings may fail", so it looks I'm out of luck here... or am I?
function substituted=`%@if["%@left[2,%@truename[%1]]"=="%1",0,1]`
works on ready drives, but fails on non-existing ones (the drives marked with an asterisk are substitutions):
[C:\Users\Miguel\TCC]pwd
NEGRO1 C:\Users\Miguel\TCC\
BLACK2 D:\
NEGRO1 *F:\
NEGRO1 *S:\
NEGRO1 *T:\
[C:\Users\Miguel\TCC]echo %@substituted[C:]
0
[C:\Users\Miguel\TCC]echo %@substituted[T:]
1
[C:\Users\Miguel\TCC]echo %@substituted[X:]
TCC: (Sys) The system cannot find the drive specified.
"X:"
I tried to improve it by prepending a %@ready call, but it didn't work:
[C:\Users\Miguel\TCC]function substituted2=`%@if["%@ready[%1]"=="1" .and. "%@left[2,%@truename[%1]]"=="%1",0,1]`
[C:\Users\Miguel\TCC]echo %@substituted2[C:]
0
[C:\Users\Miguel\TCC]echo %@substituted2[T:]
1
[C:\Users\Miguel\TCC]echo %@substituted2[X:]
TCC: (Sys) The system cannot find the drive specified.
"X:"
I tried to nest to %@if calls instead:
[C:\Users\Miguel\TCC]function substituted3=`%@if["%@ready[%1]"=="1",%@if["%@left[2,%@truename[%1]]"=="%1",0,1],2]`
[C:\Users\Miguel\TCC]echo %@substituted3[C:]
0
[C:\Users\Miguel\TCC]echo %@substituted3[T:]
1
[C:\Users\Miguel\TCC]echo %@substituted3[X:]
TCC: (Sys) The system cannot find the drive specified.
"X:"
... and it doesn't work either.
The help page for @if states "Do not use @IF if evaluating either one of the strings may fail", so it looks I'm out of luck here... or am I?