输入一串字符,就可自动计算字符串的长度,主要是计算字符串长度的那段命令想不出,哪位高人给详细分析一下,先谢谢各位了!
联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!
@echo off
set/p l=please input a string:
:lp
set /a n+=1
set l=%l:~1%
if defined l goto :lp
echo string.len is %n%
pause
@echo off
set /p str=请输入:
set length=0
for /f "skip=1 delims=:" %%a in ('^(echo "%str%"^&echo.^)^|findstr /o ".*"') do set /a length=%%a-5
echo %length%
@echo off
set /p str=请输入:
set length=0
echo "%str%">"%temp%\strlen.txt"
for %%a in ("%temp%\strlen.txt") do set length=%%~za
set /a length=length-4
echo %length%
wsh.echo len(inputbox(""))
%~I - expands %I removing any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
%~$PATH:I - searches the directories listed in the PATH
environment variable and expands %I to the
fully qualified name of the first one found.
If the environment variable name is not
defined or the file is not found by the
search, then this modifier expands to the
empty string