Welcome!

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

SignUp Now!

Do /L again

Jun
98
0
Hello.

My issue:

I'm parsing string using Do /L with delimiter /T

Code:
*Do item in /T";" /L .COM;.EXE;.BAT;.CMD
   *Echo ^>%[item]^<
*EndDo
Works, as expected.

Now I want to add at the first position an empty item:
Code:
*Do item in /T";" /L ;.COM;.EXE;.BAT;.CMD
   *Echo ^>%[item]^<
*EndDo
Works as previous code, unexpected

But it is possible to add an empty item at the end. This example works as expected:
Code:
*Do item in /T";" /L .COM;.EXE;.BAT;.CMD;
   *Echo ^>%[item]^<
*EndDo

Any suggestions?
 
This won't work in general, but if you're processing file extension strings, try using just a "." as the first item like
Code:
*Do item in /T";" /L  .;.COM;.EXE;.BAT;.CMD
 
A bit of a kludge:
Code:
v:\> do i in /T";" /L ^k^k;a;b;c; ( echo **%i** )
****
**a**
**b**
**c**
****
 
Wow.
Code:
do i in /T";" /L ^k^k;a;b;c; ( echo **%i** )
Magic :) Please explain - I have no idea.
^k is an escape sequence for the backquote. If you put a literal `` there, it would disappear too soon. The escape sequence delays that. That's the best I can do. Others seem to understand TCC's parsing better than I do.
 
Something to think about:
Code:
v:\> echo ``


v:\> echo ^k^k
``

v:\> echo %@execstr[echo ^k^k]


v:\> echo %@execstr[echo ^^k^^k]
``

v:\> echo %@execstr[echo ^^^k^^^k]
``
 
Last edited:
Hmm... Looks OK, but... in
Code:
do i in /T";" /L ^k^k;a;b;c ( echo %i )
The result is
Code:
a
b
c
I would expect to get
Code:
ECHO OFF
a
b
c

Unescaped ^k^k is discarded by echo, but it is not an empty string:
Code:
do i in /T";" /L ^k^k;a;b;c ( echo %@len[%i] )
do i in /T";" /L ^k^k;a;b;c ( echo %@quote[%i] )

May be, solution of my issue doesn't exist :( I've decided to add some logic to my script.
 

Similar threads

Back
Top