本帖最后由 neorobin 于 2014-10-20 00:20 编辑
在 WIN7 64 位下
1.- set _==5
- echo %_=%
- set /a %_=% + 3
复制代码 输出复制代码 2.- set _==5
- echo %_%
- echo %_=%
- set /a %_=% + 3
复制代码 输出复制代码 3.- set _==5
- echo %_=%
- echo %_%
- set /a %_=% + 3
复制代码 输出复制代码 以下代码做了一些测试:
当变量名尾部为若干个等号时, 例如:
$=====
_========
能否用 set 命令对这样的变量成功赋值? 如果成功赋值, 那么可以用怎样的形式做变量扩展
当在 WIN XP 32bit 下测试时, 未能对这样的变量成功赋值;
但当在 WIN7 64bit 下测试时, 某些形式 可以扩展, 但另一些形式却未成成功 扩展, 而其中的规律暂不明.
当以下划线 _ 为变量名首字符时, 尾部等号的个数为 1, 2, 5, 6, 10, 11, 14, 17, 20 以及超过 20 个时, 可成功扩展.
而当变量名首字符为 $ 时, 尾部等号的个数达到 20 以及超过 20 个时, 可成功扩展, 当首字符换成: @ # ; 时, 也得到这样的结果
测试代码:- @echo off & mode 160, 1000
-
- set _====================================================================================================VAL
- set $====================================================================================================VAL
- set #====================================================================================================VAL
- set @====================================================================================================VAL
- set ;====================================================================================================VAL
-
- REM will report: The syntax of the command is incorrect.
- set =====================================================================================================VAL
-
- echo _ is [%_%]
- echo _= is [%_=%]
- echo _== is [%_==%]
- echo _=== is [%_===%]
- echo _==== is [%_====%]
- echo _===== is [%_=====%]
- echo _====== is [%_======%]
- echo _======= is [%_=======%]
- echo _======== is [%_========%]
- echo _========= is [%_=========%]
- echo _========== is [%_==========%]
- echo _=========== is [%_===========%]
- echo _============ is [%_============%]
- echo _============= is [%_=============%]
- echo _============== is [%_==============%]
- echo _=============== is [%_===============%]
- echo _================ is [%_================%]
- echo _================= is [%_=================%]
- echo _================== is [%_==================%]
- echo _=================== is [%_===================%]
- echo _==================== is [%_====================%]
- echo _===================== is [%_=====================%]
- echo _====================== is [%_======================%]
- echo _======================= is [%_=======================%]
- echo _======================== is [%_========================%]
- echo _========================= is [%_=========================%]
- echo _========================== is [%_==========================%]
- echo _=========================== is [%_===========================%]
- echo _============================ is [%_============================%]
- echo _============================= is [%_=============================%]
- echo _============================== is [%_==============================%]
- echo _=============================== is [%_===============================%]
- echo _================================ is [%_================================%]
- echo _================================= is [%_=================================%]
- echo _================================== is [%_==================================%]
- echo _=================================== is [%_===================================%]
- echo _==================================== is [%_====================================%]
- echo _===================================== is [%_=====================================%]
-
- pause
-
- echo $ is [%$%]
- echo $= is [%$=%]
- echo $== is [%$==%]
- echo $=== is [%$===%]
- echo $==== is [%$====%]
- echo $===== is [%$=====%]
- echo $====== is [%$======%]
- echo $======= is [%$=======%]
- echo $======== is [%$========%]
- echo $========= is [%$=========%]
- echo $========== is [%$==========%]
- echo $=========== is [%$===========%]
- echo $============ is [%$============%]
- echo $============= is [%$=============%]
- echo $============== is [%$==============%]
- echo $=============== is [%$===============%]
- echo $================ is [%$================%]
- echo $================= is [%$=================%]
- echo $================== is [%$==================%]
- echo $=================== is [%$===================%]
- echo $==================== is [%$====================%]
- echo $===================== is [%$=====================%]
- echo $====================== is [%$======================%]
- echo $======================= is [%$=======================%]
- echo $======================== is [%$========================%]
- echo $========================= is [%$=========================%]
- echo $========================== is [%$==========================%]
- echo $=========================== is [%$===========================%]
- echo $============================ is [%$============================%]
- echo $============================= is [%$=============================%]
- echo $============================== is [%$==============================%]
- echo $=============================== is [%$===============================%]
- echo $================================ is [%$================================%]
- echo $================================= is [%$=================================%]
- echo $================================== is [%$==================================%]
- echo $=================================== is [%$===================================%]
- echo $==================================== is [%$====================================%]
- echo $===================================== is [%$=====================================%]
-
- pause
复制代码 输出结果- The syntax of the command is incorrect.
- _ is [===================================================================================================VAL]
- _= is [==================================================================================================VAL]
- _== is [=================================================================================================VAL]
- _=== is []
- _==== is []
- _===== is [==============================================================================================VAL]
- _====== is [=============================================================================================VAL]
- _======= is []
- _======== is []
- _========= is []
- _========== is [=========================================================================================VAL]
- _=========== is [========================================================================================VAL]
- _============ is []
- _============= is []
- _============== is [=====================================================================================VAL]
- _=============== is []
- _================ is []
- _================= is [==================================================================================VAL]
- _================== is []
- _=================== is []
- _==================== is [===============================================================================VAL]
- _===================== is [==============================================================================VAL]
- _====================== is [=============================================================================VAL]
- _======================= is [============================================================================VAL]
- _======================== is [===========================================================================VAL]
- _========================= is [==========================================================================VAL]
- _========================== is [=========================================================================VAL]
- _=========================== is [========================================================================VAL]
- _============================ is [=======================================================================VAL]
- _============================= is [======================================================================VAL]
- _============================== is [=====================================================================VAL]
- _=============================== is [====================================================================VAL]
- _================================ is [===================================================================VAL]
- _================================= is [==================================================================VAL]
- _================================== is [=================================================================VAL]
- _=================================== is [================================================================VAL]
- _==================================== is [===============================================================VAL]
- _===================================== is [==============================================================VAL]
- Press any key to continue . . .
- $ is [===================================================================================================VAL]
- $= is []
- $== is []
- $=== is []
- $==== is []
- $===== is []
- $====== is []
- $======= is []
- $======== is []
- $========= is []
- $========== is []
- $=========== is []
- $============ is []
- $============= is []
- $============== is []
- $=============== is []
- $================ is []
- $================= is []
- $================== is []
- $=================== is []
- $==================== is [===============================================================================VAL]
- $===================== is [==============================================================================VAL]
- $====================== is [=============================================================================VAL]
- $======================= is [============================================================================VAL]
- $======================== is [===========================================================================VAL]
- $========================= is [==========================================================================VAL]
- $========================== is [=========================================================================VAL]
- $=========================== is [========================================================================VAL]
- $============================ is [=======================================================================VAL]
- $============================= is [======================================================================VAL]
- $============================== is [=====================================================================VAL]
- $=============================== is [====================================================================VAL]
- $================================ is [===================================================================VAL]
- $================================= is [==================================================================VAL]
- $================================== is [=================================================================VAL]
- $=================================== is [================================================================VAL]
- $==================================== is [===============================================================VAL]
- $===================================== is [==============================================================VAL]
- Press any key to continue . . .
复制代码
|