I have scripted VLen.bat to determine the length of a string.
The syntax for using VLen.bat is:
call VLen String Length
where String is the string whose length you want to determine, and Length is a call directed numeric environment variable that will contain the length of the string.
NOTE: See A better way to determine the position and length of a sub-string in a string.
VLen.bat contains:
@echo off if \{%2\}==\{\} @echo Syntax: call VLen String Length&goto :EOF set /a %2 = 0 if exist "%TEMP%\VLen.vbs" goto vl @echo dim str>"%TEMP%\VLen.vbs" @echo Set objshell = CreateObject("WScript.Shell")>>"%TEMP%\VLen.vbs" @echo Set objArgs = WScript.Arguments>>"%TEMP%\VLen.vbs" @echo str=objArgs(0)>>"%TEMP%\VLen.vbs" @echo wscript.echo Len(str)>>"%TEMP%\VLen.vbs" :vl for /f "Tokens=*" %%a in ('cscript.exe //nologo "%TEMP%\VLen.vbs" %1') do ( set /a %2=%%a )
0 comments
Hide comments