本帖最后由 /zhqsystem/zhq 于 2016-11-22 03:49 编辑
回复 1# vq86
- @echo off&setlocal enabledelayedexpansion
- set "数值=1234567890"
- set "取值位数=8000"
- rem:以下到pause前如果存在复式内用!替换%
- set "Character=%数值%"&&rem:此行为必须行
- set "Character_contrast=%取值位数%"&&rem:此行为必须行
- call :强制补0 &&rem:调用其中一种
- call :检测补0 &&rem:调用其中一种
- set "数值=!Character!"&&rem:此行为必须行
- echo,!数值!&&rem:此行为必须行
- pause
- goto:eof
- :检测补0
- rem:数值取值N位,不足时高位用 0 补足,超出时则去除高位
- set "Character_Numbers_span=50"
- set "Character_Numbers_Small="&&for /l %%n in (0,!Character_Numbers_span!,8192)do if /i not "!Character:~%%~n,1!"=="" (set "Character_Numbers_Small=%%~n")
- set/a "Character_Numbers_large=%Character_Numbers_Small%+%Character_Numbers_span%+1"
- set "Character_Numbers="&&for /l %%n in (!Character_Numbers_Small!,1,!Character_Numbers_large!)do if /i not "!Character:~%%~n,1!"=="" (set/a "Character_Numbers=%%~n+1")
- if %Character_Numbers% equ %Character_contrast% (rem:
- )else if %Character_Numbers% GTR %Character_contrast% (rem:
- set "Character=!Character:~-%Character_contrast%!"
- )else if %Character_Numbers% LSS %Character_contrast% (rem:
- for /l %%n in (%Character_Numbers%,1,%Character_contrast%)do set "Character=0!Character!"
- set "Character=!Character:~-%Character_contrast%!"
- )
- goto:eof
- :强制补0
- for /l %%n in (1,1,%Character_contrast%)do set "Character=0!Character!"
- set "Character=!Character:~-%Character_contrast%!"
- goto:eof
复制代码
|