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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
vvomble
Posts: 9
Joined: 08 Jul 2013 07:07

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

#1 Post by vvomble » 30 Jul 2013 13:40

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

Squashman
Expert
Posts: 4477
Joined: 23 Dec 2011 13:59

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

#2 Post by Squashman » 30 Jul 2013 13:47

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

vvomble
Posts: 9
Joined: 08 Jul 2013 07:07

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

#3 Post by vvomble » 30 Jul 2013 14:18

that didn't work it still shows as

Code: Select all

you requested   is that correct?

jeb
Expert
Posts: 1043
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

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

#4 Post by jeb » 30 Jul 2013 14:22

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=

vvomble
Posts: 9
Joined: 08 Jul 2013 07:07

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

#5 Post by vvomble » 30 Jul 2013 14:39

unfortunately neither of those were right although the

Code: Select all

set /p platform=


wasn't something I'd spotted. thanks

vvomble
Posts: 9
Joined: 08 Jul 2013 07:07

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

#6 Post by vvomble » 30 Jul 2013 22:34

Any other ideas guys as so far this is drawing a blank. Your patience and time are appreciated guys oh and girls

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

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

#7 Post by foxidrive » 30 Jul 2013 23:58

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

vvomble
Posts: 9
Joined: 08 Jul 2013 07:07

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

#8 Post by vvomble » 31 Jul 2013 00:16

thanks that worked it's been bugging me for days

Post Reply