Re: How to through a semicolon separated list in a string

From: Matthias Tacke (Matthias_at_Tacke.de)
Date: 05/22/04


Date: Sat, 22 May 2004 18:41:22 +0200


"Csaba Gabor" wrote:
>"Matthias Tacke" <Matthias@Tacke.de> wrote in message
>> "Csaba Gabor" wrote:
<snip>
>> IMO formatting with breaks at natural points after ( and in front of )
>> is better readable:
>>
>> @echo off
>> FOR /F "tokens=1,* delims=:" %%G IN (
>> 'c:\sqlite.exe c:\Mydb "SELECT Id||':'||myList FROM myTable;"'
>> ) DO ECHO %%G-^>%%H
>
>This is good to know, thanks. Can natural and batch be in the
>same sentence?
With "natural" I only meant that you can break lines at that points
without problems. The shells ignores these breaks.

And yes, you may mix with the line continuation symbol ^

<snip>
>I reposted because the title of this post is messed up and perhaps
>my solution there is simpler, but yours is more educational for me.
>In particular, if I read yours correctly, it is more general. The general
>idea of what you're doing is clear, but the specifics interest me very
>much. Where can I read the documentation about this ! form, which
>I haven't seen before (I can't search for that on google, after all). It
>seems like you're doing that replace that I'm after, yes? But I'd really
>like to understand this exclamation syntax on both the second
>set line, and the Call.
See set /?

The ! instead of a % is for delayed expansion. Normally vars used inside
an area enclosed in parenthes are evaluated by the shell only once. To
force the changed value being used you have to either use tricks with
call's or use delayed expansion (available from w2k on) Delayed expansion
must be explicitly enabled with setlocal.
See setlocal /?

Calls to internal subs must be preceeded with a colon.
See call /?

>
>Also, what does the slash (/) after the echo and the tilde (~)
>accomplish?
As Jim already pointed out the / is a valid delimiter I used to avoid
an echo status being displayed when the contents of the var is empty.
see scho /?
>I read that && is a conditional continuation (only
>do the part to the right if the part to the left is not "false". Is
>& simply a distinct command separator (which is what unconditional
>continuation is)? Actually, if you have a recommended link that
>explains these types of language basics, that would be just great.
>
As Jim already pointed out, see my signature :-)

-- 
Greetings
Matthias________________________________________
For help on nt commands enter in a cmd window:
W2K>HH windows.chm::ntcmds.htm  XP>HH ntcmds.chm


Relevant Pages