1.

Solve : List of choices in a batch file?

Answer»

Ok, i'm trying to work out how to make a list of options for different songs on my computer, i'm pretty noob to this but i hope you will still help me.

Example:

1. Song 1

2. Song 2

*User press 2 on keypad*

*Song 2 opens"

I know how to OPEN the songs from a batch file, i just need to know how to make the choices menu for the users input.No problem.

Code: [Select]Set /p var=Choose your preferred song:
IF "%var%"=="1" GOTO 1
IF "%var%"=="2" GOTO 2

:1
[insert code for playing song 1 here]

:2
[insert code for playing song 2 here]
You can change the word "var" to ANYTHING you want, so long as you're consistent. Also note that if you want, and if the code for opening the songs is one line, you can do without the GOTO and just SAY:

Code: [Select]IF "%var%"=="1" [song code]
However, I find this more organized and you can reference it later in a LARGE batch file.

You can also secure your choices with this:

Code: [Select]:choice
Set /p var=Choose your preferred song:
IF "%var%"=="1" GOTO 1
IF "%var%"=="2" GOTO 2

ECHO Please try again. This is not a valid choice.
GOTO choice

:1
[insert code for playing song 1 here]

:2
[insert code for playing song 2 here]
The ECHO bit will only show if the user does not press 1 or 2.

Good luck. 8-)Thanks .

I've also made one for opening programs. I've searched the internet and the part on this site but i can't get a working delay between two commands(that each open a program). How do i set a delay between those two particular commands?

Example:

[Open first program]
*1-1.5 min delay*
[Open second program]Forgive me, im an idiot lol. Considering i've done some C++ programming you'd think i WOULD have considered 'Sleep', and maybe looked a little harder on this particular website? Anyway, thanks for the help Anytime.



Discussion

No Comment Found