Re: Re: String Indexing
From: Jerold Schulman (Jerry_at_jsiinc.com)
Date: 04/01/04
- Next message: Rob P: "Re: logging batch files"
- Previous message: Jerold Schulman: "Re: logging batch files"
- In reply to: Brown Delivers: "Re: String Indexing"
- Next in thread: Phil Robyn [MVP]: "Re: String Indexing"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 01 Apr 2004 09:26:54 -0500
See tip 4860 in the 'Tips & Tricks' at http://www.jsiinc.com
I guess if it no label is specified it simply parses the strings and runs the
command.
On Thu, 1 Apr 2004 04:23:39 -0800, "Brown Delivers"
<anonymous@discussions.microsoft.com> wrote:
>Thanks Phil.
>
>The first version (for 2000 and above) makes sense to me
>but I'm curious as to how version two (for NT and above)
>works.
>
>If the line
>
>call Set Progress=%%Total:~0,%X%%%
>
>is replaced with
>
>call :Set Progress=%%Total:~0,%X%%%
>
>the shell complains "The system cannot find the batch
>label specified - Set". This makes sense since their is
>no label explicitly defined as Set. However, why or how
>does it work without the colon?
>
>>-----Original Message-----
>>Brown Delivers wrote:
>>> Can a varible not be used to indicate the "length" when
>>> string indexing? This is what I observe:
>>>
>>> Set Total=********************
>>> Set X=10
>>> Set Progress=%Total:~0,10%
>>>
>>> C:\>ECHO %Progress%
>>> **********
>>>
>>> Now, say I try to use variable X to indicate the length:
>>>
>>> Set Progress=%Total:~0,%X%%
>>>
>>> C:\>ECHO %Progress%
>>> X%%
>>>
>>> What am I doing wrong?
>>
>>The first version below is for Win2000 or newer versions
>of NT:
>>
>><Win2000> c:\cmd>demo\StrIndex
>>Progress=**********
>>
>><Win2000> c:\cmd>rlist demo\StrIndex.cmd
>>=====begin c:\cmd\demo\StrIndex.cmd ====================
>>1. @echo off
>>2. setlocal enabledelayedexpansion
>>3. Set Total=********************
>>4. Set X=10
>>5. Set Progress=!Total:~0,%X%!
>>6. Set Progress
>>=====end c:\cmd\demo\StrIndex.cmd ====================
>>
>>The following version is for NT 4.0 (but will work in any
>version
>>of NT):
>>
>><Win2000> c:\cmd>demo\StrIndexNT40
>>Progress=**********
>>
>><Win2000> c:\cmd>rlist demo\StrIndexNT40.cmd
>>=====begin c:\cmd\demo\StrIndexNT40.cmd
>====================
>>1. @echo off
>>2. setlocal
>>3. Set Total=********************
>>4. Set X=10
>>5. call Set Progress=%%Total:~0,%X%%%
>>6. Set Progress
>>=====end c:\cmd\demo\StrIndexNT40.cmd
>====================
>>
>>--
>>Phil Robyn
>>Univ. of California, Berkeley
>>
>>u n z i p m y a d d r e s s t o s e n d e - m a
>i l
>>.
>>
Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
- Next message: Rob P: "Re: logging batch files"
- Previous message: Jerold Schulman: "Re: logging batch files"
- In reply to: Brown Delivers: "Re: String Indexing"
- Next in thread: Phil Robyn [MVP]: "Re: String Indexing"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|