What's wrong with this code?

March 13, 2012 at 20:55:10
Specs: Windows 7
This code doesn't work:
@echo off && setlocal ENABLEDELAYEDEXPANSION
:start
set type = 3
set ty = 0
:typea
set /a ty += 1
choice /C:ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 /N
if %errorlevel% == 1 set v%ty% = A
if %errorlevel% == 2 set v%ty% = B
if %errorlevel% == 3 set v%ty% = C
if %errorlevel% == 4 set v%ty% = D
if %errorlevel% == 5 set v%ty% = E
if %errorlevel% == 6 set v%ty% = F
if %errorlevel% == 7 set v%ty% = G
if %errorlevel% == 8 set v%ty% = H
if %errorlevel% == 9 set v%ty% = I
if %errorlevel% == 10 set v%ty% = J
if %errorlevel% == 11 set v%ty% = K
if %errorlevel% == 12 set v%ty% = L
if %errorlevel% == 13 set v%ty% = M
if %errorlevel% == 14 set v%ty% = N
if %errorlevel% == 15 set v%ty% = O
if %errorlevel% == 16 set v%ty% = P
if %errorlevel% == 17 set v%ty% = Q
if %errorlevel% == 18 set v%ty% = R
if %errorlevel% == 19 set v%ty% = S
if %errorlevel% == 20 set v%ty% = T
if %errorlevel% == 21 set v%ty% = U
if %errorlevel% == 22 set v%ty% = V
if %errorlevel% == 23 set v%ty% = W
if %errorlevel% == 24 set v%ty% = X
if %errorlevel% == 25 set v%ty% = Y
if %errorlevel% == 26 set v%ty% = Z
if %errorlevel% == 27 set v%ty% = 1
if %errorlevel% == 28 set v%ty% = 2
if %errorlevel% == 29 set v%ty% = 3
if %errorlevel% == 30 set v%ty% = 4
if %errorlevel% == 31 set v%ty% = 5
if %errorlevel% == 32 set v%ty% = 6
if %errorlevel% == 33 set v%ty% = 7
if %errorlevel% == 34 set v%ty% = 8
if %errorlevel% == 35 set v%ty% = 9
if %errorlevel% == 36 set v%ty% = 0
set num = 0
set string = ""
:show_string
set /a num += 1
set string = %string%!v%num%!
if %ty% == %num% (
	echo.%string%>>"String.txt"
	echo.%string%
	goto typea
)
goto show_string

It gives no error. But it just echos a blank line not the string variable.

See More: Whats wrong with this code?

Report •


#1
March 14, 2012 at 01:16:37
For a start all the Set commands and If commands are incorrect for the way you want to use them. Enter Set /? and If /? at the Command Prompt for info (Tip: Remove the spaces!!)

Report •
Related Solutions


Ask Question