批处理中的数组

SET Obj_Length=2
SET Obj[0].Name=Test1
SET Obj[0].Value=Hello World
SET Obj[1].Name=Test2
SET Obj[1].Value=blahblah

SET Obj_Index=0
:LoopStart
IF %Obj_Index% EQU %Obj_Length% GOTO :EOF
SET Obj_Current.Name=0
SET Obj_Current.Value=0
FOR /F"usebackq delims==. tokens=1-3"%%I IN (`SET Obj[%Obj_Index%]`) DO (
   SET Obj_Current.%%J=%%K
)
ECHO Name = %Obj_Current.Name%
ECHO Value = %Obj_Current.Value%
ECHO.
SET /AObj_Index=%Obj_Index% + 1

GOTO LoopStart

--

输出结果:

Name = Test1
Value = Hello World

Name = Test2
Value = blahblah

你可能感兴趣的:(批处理中的数组)