Associative array/Creation: Difference between revisions

Batch file version ... (puts on flameproof suit)
m ("header|F_sharp" -> "header|F Sharp")
(Batch file version ... (puts on flameproof suit))
Line 213:
Loop, 4
Msgbox % arrayX%A_Index%</lang>
 
=={{header|Batch File}}==
This is cheating, I'm sure of it.
 
<lang dos>::arrays.cmd
@echo off
setlocal ENABLEDELAYEDEXPANSION
set array.dog=1
set array.cat=2
set array.wolf=3
set array.cow=4
for %%i in (dog cat wolf cow) do call :showit array.%%i !array.%%i!
set c=-27
call :mkarray sicko flu 5 measles 6 mumps 7 bromodrosis 8
for %%i in (flu measles mumps bromodrosis) do call :showit "sicko^&%%i" !sicko^&%%i!
endlocal
goto :eof
 
:mkarray
set %1^&%2=%3
shift /2
shift /2
if "%2" neq "" goto :mkarray
goto :eof
 
:showit
echo %1 = %2
goto :eof
</lang>
 
Output:
<pre>array.dog = 1
array.cat = 2
array.wolf = 3
array.cow = 4
"sicko&flu" = 5
"sicko&measles" = 6
"sicko&mumps" = 7
"sicko&bromodrosis" = 8</pre>
 
=={{header|C}}==
Anonymous user