1.

Solve : Batch Script Problem...?

Answer»

hi all,

i have recently been getting frustrated with this script that i am making as everything itry does not work,

BASICALLY the script asks the user how many drives does it want to set then asks them or the drives in question

CODE: [Select]:drives
echo How many drives do you want to set?
set /p drives=Drives:
set /a drives = %drives% +1
set /a a = 1
:set
set /p d%a% =Drive%a%:

set /a a = %a% + 1
if not %a% == %drives% goto set

echo Drives Set!
pause


i am having trouble echoing the d%a% value


any help will be GRATEFUL thank you !This is what I got. Is it supposed to do something else? I answered r, s, t as you can see...

Code: [Select]How many drives do you want to set?
Drives: 3
Drive1: r
Drive2: s
Drive3: t
Drives Set!
Press any key to CONTINUE . . .

as i said in my first post i want to echo the value of d%a%

al you have done is input 3 letters and there is no output, and before you say yes there is....there isnt.Oh I get it. You want something like an array.

Yes, i have read many batch file help websites but nothing makes any sense to me and nothing has worked so far, i would know how to do this in VB tho lol.

so yer im looking to create an array and then echo the array values.batch language does not have arrays.
ah right, is there any way i could do this then?vbscript would be easiest.
hmm but this is only a code snippet from my full program. was hoping i could solve this without having to change scripting type.You need call set and call echo.

Code: [Select]@echo off
set cnt=0
:loop
set /a cnt+=1
call set var%%cnt%%=value%cnt%
call echo %%value%%cnt%%%=%%var%cnt%%%
if %cnt% LSS 9 goto :loop ok thanks, but how would i alter this for user input?


edit - never mind ive figured it out

Code: [Select]@echo off
set cnt=0
:loop
set /a cnt+=1
call set /p var%%cnt%%=value%cnt%:
call echo %%var%cnt%%%
if %cnt% LSS 9 goto :loop
pause



Discussion

No Comment Found