1.

Solve : Making a Batch File Questions..?

Answer»

I've always had a few questions about a batch file but could never figure out the right way to ask them..Well my friend made a file recently and had the same questions so I'm going to use this to my advantage...
Here is the code:
@ECHO OFF
title qabf
setlocal
set OK=N
GOTO ONE
set /p xxx=wrong entry, press any key to exit.
endlocal
goto end

:one
set /p choice=How old are you? [12] [13] [14]
if [%choice%]==[12] goto place
if [%choice%]==[13] goto place
if [%choice%]==[14] goto place

:place
set /p choice=Where do you want to move when you grow up? [Atlanta] [Chicago] [Brazil]
if [%choice%]==[Atlanta] goto kids
if [%choice%]==[Chicago] goto kids
if [%choice%]==[Brazil] goto kids

:kids
set /p choice=How many kids do you want? [1] [2] [3] [4] [5]
if [%choice%]==[1] goto with who
if [%choice%]==[2] goto with who
if [%choice%]==[3] goto with who
if [%choice%]==[4] goto with who
if [%choice%]==[5] goto with who

:with who
set /p choice= With Who...? Pick one of the numbers 14-20
if [%choice%]==[14] exec fourteen.txt
if [%choice%]==[15] exec fifteen.txt
if [%choice%]==[16] exec sixteen.txt
if [%choice%]==[17] exec seventeen.txt
if [%choice%]==[18] exec eighteen.txt
if [%choice%]==[19] exec ninteen.txt
if [%choice%]==[20] exec twenty.txt

the text will have the results in it...How do I make it copy them or something instead of having to make each and everyone out which will take forever?

How can you get DOS to copy the choices you pick so it can paste it to a txt file and save it to their computer and open it so that it will show the reslts..As you can tell it would take a long time to make a different subchoice for every single chice and answer and. If thats not possible then how can you make this file without having to make LOTS and LOTS or subgroups..Is there no simple way..? I ALSO had another question ...If you want DOs toread a line you do GOTO 1
Well if you want to make another 1 for another choice how do you do it without it going to the other one at the begening of your batch file..I want the first 1 to only work once so I can have another 1 to goto..If not possible any other similiar thing I can do...Thanks in advance


Batch language is not QBasic nor is it much of a scripting language. That said, your friend's batch file is a mess.

Code: [Select]
GOTO ONE
set /p xxx=wrong entry, press any key to exit.
endlocal


The set and endlocal will never be executed. Preceeded by an UNCONDITIONAL goto. Also there is no title statement in batch but as written will execute a program named title and pass qabf as a parameter..

Your set /p choice instructions are OK but they make no allowance for a incorrect response.

goto with who? Questionable. Probably an illegal label name, but you may get AWAY with it or the batch file will hunt for a :with label.

exec fourteen, fifteen etc probably don't do what you expect. As written you're executing a program named exec and passing fourteen.txt, fifteen.txt etc as parameters. There is no exec keyword in batch.

goto 1 is fine so long as you define a label named :1

If you wish to LOG a response to a file, simply redirect it (ex. echo %choice% > response.txt.

Sorry to be so critical, but a good library book explaining the wonders of batch language would prove helpful to you and your buddies.

@ECHO OFF
title qabf
setlocal
set OK=N
GOTO ONE
set /p xxx=wrong entry, press any key to exit.


:one
set /p choice=How old are you? [12] [13] [14]
if [%choice%]==[12] goto place
if [%choice%]==[13] goto place
if [%choice%]==[14] goto place

:place
set /p choice=Where do you want to move when you grow up? [Atlanta] [Chicago] [Brazil]
if [%choice%]==[Atlanta] goto kids
if [%choice%]==[Chicago] goto kids
if [%choice%]==[Brazil] goto kids

:kids
set /p choice=How many kids do you want? [1] [2] [3] [4] [5]
if [%choice%]==[1] goto with who
if [%choice%]==[2] goto with who
if [%choice%]==[3] goto with who
if [%choice%]==[4] goto with who
if [%choice%]==[5] goto with who

:with who
set /p choice= With Who...? Pick one of the numbers 14-20
if [%choice%]==[14] exec fourteen.txt
if [%choice%]==[15] exec fifteen.txt
if [%choice%]==[16] exec sixteen.txt
if [%choice%]==[17] exec seventeen.txt
if [%choice%]==[18] exec eighteen.txt
if [%choice%]==[19] exec ninteen.txt
if [%choice%]==[20] exec twenty.txt



Discussion

No Comment Found