Page 1 of 1

ifs and sets in the same line of code???

Posted: 30 Jul 2013 13:40
by vvomble
Can't seem to get this to work right for me now i'm wondering if it is possible to do.

Code: Select all

:itemspec
echo.
echo Which platform would you like to mod?
echo 1 Nes
echo 2 Master System
echo please enter category number
set /p %platform%=

if %platform%== 1 set %platform2%=Nes"
if %platform%== 1 goto Nes

if %platform%== 2 set %platform2%=MasterSystem
if %platform%== 2 goto MasterSystem


If still a complete noob at batch so not sure what the do's and don't's are yet other than this is a don't (otherwise this would work)

Thanks in advance

Re: ifs and sets in the same line of code???

Posted: 30 Jul 2013 13:47
by Squashman
if "%platform%"=="1" set %platform2%=Nes

Re: ifs and sets in the same line of code???

Posted: 30 Jul 2013 14:18
by vvomble
that didn't work it still shows as

Code: Select all

you requested   is that correct?

Re: ifs and sets in the same line of code???

Posted: 30 Jul 2013 14:22
by jeb

Code: Select all

if "%platform%"=="1" set platform2=Nes

Is better ...

At the left side of the equal sign of a SET command should only be the name without percents.

The same is true for the

Code: Select all

SET/p platform=

Re: ifs and sets in the same line of code???

Posted: 30 Jul 2013 14:39
by vvomble
unfortunately neither of those were right although the

Code: Select all

set /p platform=


wasn't something I'd spotted. thanks

Re: ifs and sets in the same line of code???

Posted: 30 Jul 2013 22:34
by vvomble
Any other ideas guys as so far this is drawing a blank. Your patience and time are appreciated guys oh and girls

Re: ifs and sets in the same line of code???

Posted: 30 Jul 2013 23:58
by foxidrive
Give this a crack. Assuming it is not inside a loop:

Code: Select all

:itemspec
set "platform="
set "platform2="
echo.
echo Which platform would you like to mod?
echo 1 Nes
echo 2 Master System
set /p "platform=please enter category number: "

if "%platform%"=="1" set "platform2=Nes" & goto Nes
if "%platform%"=="2" set "platform2=MasterSystem" & goto MasterSystem
if not defined platform2 goto :itemspec

Re: ifs and sets in the same line of code???

Posted: 31 Jul 2013 00:16
by vvomble
thanks that worked it's been bugging me for days