home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
magazine
/
pcmagazi
/
1992
/
13
/
getlngth.bat
< prev
next >
Wrap
DOS Batch File
|
1992-01-16
|
936b
|
31 lines
@ECHO OFF
Rem ### Get the length of Environment Variable STRING, ###
Rem ### set to the value of %1 on entry. Set the length ###
Rem ### in Environment Variable LENGTH. Lengths greater ###
Rem ### than nine characters set LENGTH equal to 9+. ###
Rem ### Variable STRING may not include the ~ character. ###
SET string=%1
IF '%string%'=='' GOTO zero
SET temp=%string%~
SET length=
:loop
SET length=+%length%
FOR %%y IN (/%temp%) DO SET temp=%%y
IF NOT %temp%==~ GOTO loop
IF %length%==+ SET length=1
IF %length%==++ SET length=2
IF %length%==+++ SET length=3
IF %length%==++++ SET length=4
IF %length%==+++++ SET length=5
IF %length%==++++++ SET length=6
IF %length%==+++++++ SET length=7
IF %length%==++++++++ SET length=8
IF %length%==+++++++++ SET length=9
FOR %%z IN (/%length%) do if %%z==+ SET length=9+
GOTO done
:zero
SET length=0
:done
SET temp=
ECHO Length of "%string%" is %length%