[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
提个错误:
在3.3 set命令详解中的例11,
@echo off
set /p str=请输入任意长度的字符串:
echo  你输入了字符串:"%str%"
call :stringlenth "%str%" num
echo  字符串长度为:%num%
pause
:stringLenth
::字符串长度计算子程序
set thestring=%~1
::参数%1 为字符串"%str%",%~1则去掉"%str%"的双引号。
if not defined theString goto :eof
set Return=0
:stringLenth_continue
set /a Return =1                              ::这句应为:set /a Return+ =1
set thestring=%thestring:~0,-1%
::偏移量为1,截取倒数第1位前的所有字符。
if defined thestring goto stringLenth_continue
if not "%2"=="" set %2=%Return%
::参数%2为返回变量num的名称,不能含空格或特殊字符。
goto :eof

TOP

返回列表