回复 16# aloha20200628
把楼主的ChangeCnToAn9999子过程修改如下,经不完全测试,好像也能实现对大写的兼容:- :: 最小段位转换函数》输出范围={ 0~9999 }
- :ChangeCnToAn9999 // %1=中文数字符串(实值) %2=返回值变量名
- if "%~1"=="零" set "%~2=0"&exit/b
- set "cn#=%~1" &set "cn#=!cn#:零=!"&set "uList=十,拾,百,佰,千,仟"
- set/a "n#=0,一=1,二=2,三=3,四=4,五=5,六=6,七=7,八=8,九=9,十=10,百=100,千=1000"
- set/a "n#=0,壹=1,贰=2,叁=3,肆=4,伍=5,陆=6,柒=7,捌=8,玖=9,拾=10,佰=100,仟=1000"
- for /L %%k in (0,2,6,8,10,12) do if "!cn#:~%%k,1!" neq "" (
- set "n2c=!cn#:~%%k,2!" &set "nc1=!n2c:~0,1!" &set "nc2=!n2c:~1,1!"
- if "!nc2!"=="" (set/a n#+=!nc1!) else for %%c in (!nc2!) do (
- if "!uList:%%c=!" neq "!uList!" (set/a n#+=!nc1!*!nc2!) else (set/a n#+=!nc1!+!nc2!)
- )
- )
- set "%~2=!n#!" &exit/b
复制代码
|