title: BATCH Scripting - Swapping array subscript values
body: <p>I'd like to start this off by saying batch scripting is something I ever do, and it's for an assignment in my class, so please bear with me. I am trying to take an array index and swap one of the indices for another. If I echo out each index after assigning it I get the expected output, but if I try to echo the array, the array hasn't changed. As I said I am very new with programming and especially batch, so I'm sure there is something fundamental I am missing.</p>
  
  <p><strong>my output</strong></p>
  
  <pre><code>if index[0] is GTR index[4] if I enter 5,4,3,2,1:
  echo %index[4]% outputs 5 %index[0] outputs 1
  echo %numbers% outputs 5,4,3,2,1
  </code></pre>
  
  <p><strong>my code</strong></p>
  
  <pre><code>@echo off
  
  set /p num1=Enter first num
  set /p num2=Enter second num
  set /p num3=Enter third num
  set /p num4=Enter foruth num
  set /p num5=Enter fifth num
  
  SET /a num1=%num1%
  SET /a num2=%num2%
  SET /a num3=%num3%
  SET /a num4=%num4%
  SET /a num5=%num5%
  
  SET numbers=%num1% %num2% %num3% %num4% %num5%
  
  (for %%x in (%numbers%) do (echo %%x))
  
  echo my array %numbers%
  
  if %num1% GTR %num5% (
      SET /A temp=%num1%
      SET numbers[0]=%num5%
      SET numbers[4]=%temp%
      echo INDEX 4 is: %numbers[4]% INDEX 1 is: %numbers[0]%
      ) else (
          echo "end of array is greater than start"
  )
  </code></pre>