so over all i need to know how to make a batch program that you can have an input that has 2 words that are parted with a space .
i really really hope someone can help
![Very Happy :D](./images/smilies/icon_biggrin.gif)
![Cool 8)](./images/smilies/icon_cool.gif)
Moderator: DosItHelp
I don't see a problem here...Bulleyeaccuracy wrote:so over all i need to know how to make a batch program that you can have an input that has 2 words that are parted with a space .
Code: Select all
>set /p ?=
hel lo
>set ?
?=hel lo
>
Code: Select all
:minecraftmainmenu
@echo off
title Minecraft World Saver
color 0A
cls
dir C:\Users\Michael\AppData\Roaming\.minecraft\saves /b
echo Please type in the name of the world which you would like to back up
echo or type "all" to back up all
set /p minecraftsaver=World name:
if %minecraftsaver%==all goto minecraftall else goto minecraftbackuperror
Code: Select all
if %minecraftsaver%==all goto minecraftall else goto minecraftbackuperror
Code: Select all
H:\>if /?
Performs conditional processing in batch programs.
IF [NOT] ERRORLEVEL number command
IF [NOT] string1==string2 command
IF [NOT] EXIST filename command
NOT Specifies that Windows XP should carry out
the command only if the condition is false.
ERRORLEVEL number Specifies a true condition if the last program run
returned an exit code equal to or greater than the number
specified.
string1==string2 Specifies a true condition if the specified text strings
match.
EXIST filename Specifies a true condition if the specified filename
exists.
command Specifies the command to carry out if the condition is
met. Command can be followed by ELSE command which
will execute the command after the ELSE keyword if the
specified condition is FALSE
The ELSE clause must occur on the same line as the command after the IF. For
example:
IF EXIST filename. (
del filename.
) ELSE (
echo filename. missing.
)
The following would NOT work because the del command needs to be terminated
by a newline:
IF EXIST filename. del filename. ELSE echo filename. missing
Nor would the following work, since the ELSE command must be on the same line
as the end of the IF command:
IF EXIST filename. del filename.
ELSE echo filename. missing
The following would work if you want it all on one line:
IF EXIST filename. (del filename.) ELSE echo filename. missing
Code: Select all
if /i "%minecraftsaver%" == "all" (goto minecraftall) else goto minecraftbackuperror
Bulleyeaccuracy wrote:i guess i could say i am ok at batch coding, but i have no idea what you ment by giving me the help for the if command.
Code: Select all
if %minecraftsaver%==all goto minecraftall (else goto minecraftbackup1)
Code: Select all
if /i "%minecraftsaver%"=="all" (goto :minecraftall) else (goto :minecraftbackuperror)
Code: Select all
if %minecraftsaver%==all (goto minecraftall) else goto minecraftbackup1
Fawers wrote:Try thisCode: Select all
if /i "%minecraftsaver%" == "all" (goto minecraftall) else goto minecraftbackuperror
Bulleyeaccuracy wrote:if you mean for me to do this...Code: Select all
if %minecraftsaver%==all goto minecraftall (else goto minecraftbackup1)
Squashman wrote:Bulleyeaccuracy wrote:if you mean for me to do this...Code: Select all
if %minecraftsaver%==all goto minecraftall (else goto minecraftbackup1)
How did you come up with that after I showed you the help file which explained how to use IF ELSE and Fawers gave you the correct syntax for using an IF ELSE with your code.
Unless these 2 words are larger than 8192-10 bytes, you are wrong, didn't you see my previous example ?Bulleyeaccuracy wrote:i am 99% sure that you can't have 2 words in the same input
Code: Select all
@echo off &setlocal enableDelayedExpansion
:init ( null )
:: (
title Minecraft World Saver &color 0A &cls
set /a $err = 0
call :main %*
echo.Is this what u wanted ?
pause
:: )
exit /b %$err%
:main ( paramRAW,# )
:: (
dir /b "C:\Users\Michael\AppData\Roaming\.minecraft\saves"
echo.Please type in the name of the world which you would like to back up
echo.or type "all" to back up all.
set /p "$=World name:" &2>nul ( call :minecraft!$! "()" ) ||call :minecraftbackuperror !$!
set /a $err = !errorLevel!
:: )
exit /b %$err%
:minecraftall ( null )
:: (
echo.Don't type 'all' please, I don't like this :@
:: )
exit /b %$err%
:minecraftbackuperror ( %1,# )
:: (
echo.Why did you type '%~1', type 'all' please, I don't like this :@
:: )
exit /b 1
Code: Select all
Please type in the name of the world which you would like to back up
or type "all" to back up all.
World name:all
Don't type 'all' please, I don't like this :@
Is this what u wanted ?
Druk op een toets om door te gaan. . .
Code: Select all
Please type in the name of the world which you would like to back up
or type "all" to back up all.
World name:whoopTiddy
Why did you type 'whoopTiddy', type 'all' please, I don't like this :@
Is this what u wanted ?
Druk op een toets om door te gaan. . .
Bulleyeaccuracy wrote:i have recoded the program to get rid of the else statment and it still does not work (if you bothered to read the histroy you would have seen that). So it has nothing to do with the if statment!!
Squashman wrote:Bulleyeaccuracy wrote:i have recoded the program to get rid of the else statment and it still does not work (if you bothered to read the histroy you would have seen that). So it has nothing to do with the if statment!!
I don't see any of your posts saying anything to that affect. If you could show me which one it is I would be more than happy to look at it.