title: hexadecimal to decimal batch file
body: <p>okay so I have been working an a batch file that converts a base ten decimal value in to hexadecimal but I can't get the for loops and the if statements down right every were I look seems to be giving me the wrong information here is my code. thank you to all that reply </p>
  
  <pre><code>@ echo off
  echo Hexa Decimal Convertor 1.0
  
  set OneOn = false
  set TwoOn = false
  set ThreeOn = false
  set FourOn = false
  set FiveOn = false
  set SixOn = false
  set SevenOn = false
  set EightOn = false
  
  set firstDig = 0
  set secondDig = 0
  
  
  set digits =  128 64 32 16 8 4 2 1 0
  
  set Total = 0
  set INPUT = 43
  
  set /p INPUT=Enter a number (0-255): 
  if %INPUT% gtr 15 goto other
  if %INPUT% == 1 echo IN HEXADECIMAL %INPUT% = %INPUT%
  if %INPUT% == 2 echo IN HEXADECIMAL %INPUT% = %INPUT%
  if %INPUT% == 3 echo IN HEXADECIMAL %INPUT% = %INPUT%
  if %INPUT% == 4 echo IN HEXADECIMAL %INPUT% = %INPUT%
  if %INPUT% == 5 echo IN HEXADECIMAL %INPUT% = %INPUT%
  if %INPUT% == 6 echo IN HEXADECIMAL %INPUT% = %INPUT%
  if %INPUT% == 7 echo IN HEXADECIMAL %INPUT% = %INPUT%
  if %INPUT% == 8 echo IN HEXADECIMAL %INPUT% = %INPUT%
  if %INPUT% == 9 echo IN HEXADECIMAL %INPUT% = %INPUT%
  if %INPUT% == 10 echo IN HEXADECIMAL %INPUT% = A
  if %INPUT% == 11 echo IN HEXADECIMAL %INPUT% = B
  if %INPUT% == 12 echo IN HEXADECIMAL %INPUT% = C
  if %INPUT% == 13 echo IN HEXADECIMAL %INPUT% = D
  if %INPUT% == 14 echo IN HEXADECIMAL %INPUT% = E
  if %INPUT% == 15 echo IN HEXADECIMAL %INPUT% = F
  pause
  :other
  for /l %%G (0, 1, 8) do (
      for /l %%F (0,1,8) do (
          for /l %%D (0,1,8) do (
              for /l %%S (0,1,8) do (
                  for /l %%A (0,1,8) do (
                      for /l %%L (0,1,8) do (
                          for /l %%K (0,1,8) do (
                              for /l %%J (0,1,8) do (
                                  for /l %%H (0,1,8) do (
  
                                      set TESTTOTAL = digit[%H%] + digit[%J%] + digit[%K%] +  digit[%L%] +  digit[%A%] + digit[%S%] + digit[%D%] + digit[%F%] + digit[%G%]
                                      if %TESTTOTAL% == %INPUT% goto match 
  
                                      )
                                  )
                              )
                          )
                      )
                  )
              )
          )
      )
  )
  
  :match
  if digit[%H%] == 1 OneOn = true
  if digit[%H%] == 2 TwoOn = true
  if digit[%H%] == 4 ThreeOn = true
  if digit[%H%] == 8 FourOn = true
  if digit[%H%] == 16 FiveOn = true
  if digit[%H%] == 32 SixOn = true
  if digit[%H%] == 64 SevenOn = true
  if digit[%H%] == 128 EightOn = true 
  
  if digit[%J%] == 1 OneOn = true
  if digit[%J%] == 2 TwoOn = true
  if digit[%J%] == 4 ThreeOn = true
  if digit[%J%] == 8 FourOn = true
  if digit[%J%] == 16 FiveOn = true
  if digit[%J%] == 32 SixOn = true
  if digit[%J%] == 64 SevenOn = true
  if digit[%J%] == 128 EightOn = true
  
  if digit[%K%] == 1 OneOn = true
  if digit[%K%] == 2 TwoOn = true
  if digit[%K%] == 4 ThreeOn = true
  if digit[%K%] == 8 FourOn = true
  if digit[%K%] == 16 FiveOn = true
  if digit[%K%] == 32 SixOn = true
  if digit[%K%] == 64 SevenOn = true
  if digit[%K%] == 128 EightOn = true
  
  if digit[%L%] == 1 OneOn = true
  if digit[%L%] == 2 TwoOn = true
  if digit[%L%] == 4 ThreeOn = true
  if digit[%L%] == 8 FourOn = true
  if digit[%L%] == 16 FiveOn = true
  if digit[%L%] == 32 SixOn = true
  if digit[%L%] == 64 SevenOn = true
  if digit[%L%] == 128 EightOn = true
  
  if digit[%A%] == 1 OneOn = true
  if digit[%A%] == 2 TwoOn = true
  if digit[%A%] == 4 ThreeOn = true
  if digit[%A%] == 8 FourOn = true
  if digit[%A%] == 16 FiveOn = true
  if digit[%A%] == 32 SixOn = true
  if digit[%A%] == 64 SevenOn = true
  if digit[%A%] == 128 EightOn = true
  
  if digit[%S%] == 1 OneOn = true
  if digit[%S%] == 2 TwoOn = true
  if digit[%S%] == 4 ThreeOn = true
  if digit[%S%] == 8 FourOn = true
  if digit[%S%] == 16 FiveOn = true
  if digit[%S%] == 32 SixOn = true
  if digit[%S%] == 64 SevenOn = true
  if digit[%S%] == 128 EightOn = true
  
  if digit[%D%] == 1 OneOn = true
  if digit[%D%] == 2 TwoOn = true
  if digit[%D%] == 4 ThreeOn = true
  if digit[%D%] == 8 FourOn = true
  if digit[%D%] == 16 FiveOn = true
  if digit[%D%] == 32 SixOn = true
  if digit[%D%] == 64 SevenOn = true
  if digit[%D%] == 128 EightOn = true
  
  if digit[%F%] == 1 OneOn = true
  if digit[%F%] == 2 TwoOn = true
  if digit[%F%] == 4 ThreeOn = true
  if digit[%F%] == 8 FourOn = true
  if digit[%F%] == 16 FiveOn = true
  if digit[%F%] == 32 SixOn = true
  if digit[%F%] == 64 SevenOn = true
  if digit[%F%] == 128 EightOn = true
  
  if digit[%G%] == 1 OneOn = true
  if digit[%G%] == 2 TwoOn = true
  if digit[%G%] == 4 ThreeOn = true
  if digit[%G%] == 8 FourOn = true
  if digit[%G%] == 16 FiveOn = true
  if digit[%G%] == 32 SixOn = true
  if digit[%G%] == 64 SevenOn = true
  if digit[%G%] == 128 EightOn = true
  
  if OneOn == true &amp; TwoOn == true &amp; ThreeOn == true &amp; FourOn == true secondDig = F
  if OneOn == true &amp; TwoOn == true &amp; ThreeOn == true &amp; FourOn == false secondDig = E
  if OneOn == true &amp; TwoOn == true &amp; ThreeOn == false &amp; FourOn == true secondDig = D
  if OneOn == false &amp; TwoOn == false &amp; ThreeOn == true &amp; FourOn == true secondDig = C
  if OneOn == true &amp; TwoOn == true &amp; ThreeOn == false &amp; FourOn == true secondDig = B
  if OneOn == false &amp; TwoOn == true &amp; ThreeOn == false &amp; FourOn == true secondDig = A
  if OneOn == true &amp; TwoOn == false &amp; ThreeOn == false &amp; FourOn == true secondDig = 9
  if OneOn == false &amp; TwoOn == false &amp; ThreeOn == false &amp; FourOn == true secondDig = 8
  if OneOn == true &amp; TwoOn == true &amp; ThreeOn == true &amp; FourOn == false secondDig = 7
  if OneOn == false &amp; TwoOn == true &amp; ThreeOn == true &amp; FourOn == false secondDig = 6
  if OneOn == true &amp; TwoOn == false &amp; ThreeOn == true &amp; FourOn == false secondDig = 5
  if OneOn == false &amp; TwoOn == false &amp; ThreeOn == true &amp; FourOn == false secondDig = 4
  if OneOn == true &amp; TwoOn == true &amp; ThreeOn == false &amp; FourOn == false secondDig = 3
  if OneOn == false &amp; TwoOn == true &amp; ThreeOn == false &amp; FourOn == false secondDig = 2
  if OneOn == true &amp; TwoOn == false &amp; ThreeOn == false &amp; FourOn == false secondDig = 1
  if OneOn == false &amp; TwoOn == false &amp; ThreeOn == false &amp; FourOn == false secondDig = 0
  
  if FiveOn == true &amp; SixOn == true &amp; SevenOn == true &amp; EightOn == true firstDig = F
  if FiveOn == true &amp; SixOn == true &amp; SevenOn == true &amp; EightOn == false firstDig = E
  if FiveOn == true &amp; SixOn == true &amp; SevenOn == false &amp; EightOn == true firstDig = D
  if FiveOn == false &amp; SixOn == false &amp; SevenOn == true &amp; EightOn == true firstDig = C
  if FiveOn == true &amp; SixOn == true &amp; SevenOn == false &amp; EightOn == true firstDig = B
  if FiveOn == false &amp; SixOn == true &amp; SevenOn == false &amp; EightOn == true firstDig = A
  if FiveOn == true &amp; SixOn == false &amp; SevenOn == false &amp; EightOn == true firstDig = 9
  if FiveOn == false &amp; SixOn == false &amp; SevenOn == false &amp; EightOn == true firstDig = 8
  if FiveOn == true &amp; SixOn == true &amp; SevenOn == true &amp; EightOn == false firstDig = 7
  if FiveOn == false &amp; SixOn == true &amp; SevenOn == true &amp; EightOn == false firstDig = 6
  if FiveOn == true &amp; SixOn == false &amp; SevenOn == true &amp; EightOn == false firstDig = 5
  if FiveOn == false &amp; SixOn == false &amp; SevenOn == true &amp; EightOn == false firstDig = 4
  if FiveOn == true &amp; SixOn == true &amp; SevenOn == false &amp; EightOn == false firstDig = 3
  if FiveOn == false &amp; SixOn == true &amp; SevenOn == false &amp; EightOn == false firstDig = 2
  if FiveOn == true &amp; SixOn == false &amp; SevenOn == false &amp; EightOn == false firstDig = 1
  if FiveOn == false &amp; SixOn == false &amp; SevenOn == false &amp; EightOn == false firstDig = 0
  
  echo in hexadecimal %INPUT% = %firstDig% %secondDig%  
  pause
  </code></pre>