Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ECHO OFF
- ::: Delayed Expansion required to access variables during operation of For Loop
- ::: Random only used for demonstration purpose. Normal use would be to define array values in a text file to be
- ::: "Loaded into" the Arrays.
- ::: For /L defines the number of arrays to be set.
- ::: For /F is where you would adjust the input for the arrays.
- SETLOCAL ENABLEDELAYEDEXPANSION
- FOR /L %%i IN (1,1,5) DO FOR /F %%j IN ('SET /A "RND=!RANDOM!*15/32768+1"') DO ECHO ARRAY[%%i] %%j && Set "aVal=%%i" && Set "Array[!aVal!]=%%j"
- ECHO %Array[1]% %Array[2]% %Array[3]% %Array[4]% %Array[5]%
- pause
Advertisement
Add Comment
Please, Sign In to add comment