Doing a random true/false =FIXED=

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Azrooh
Posts: 1
Joined: 20 Nov 2010 12:23

Doing a random true/false =FIXED=

#1 Post by Azrooh » 20 Nov 2010 12:29

if %something% ==1 (echo true) else (echo false)







I'm working on a batch file to randomize a config file, but I've run into a hitch for the true/false options.
I've got a system working to randomly pick a 1 or a 2, but how would I go about doing this:
If number is 1, set a variable=true
Else set a variable=false

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

Re: Doing a random true/false =FIXED=

#2 Post by jeb » 21 Nov 2010 05:41

Hi Azrooh,

this should work

Code: Select all

set /a r=%random% %% 2
if %r%==1 (echo true) else (echo false)


hope it helps

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: Doing a random true/false =FIXED=

#3 Post by !k » 21 Nov 2010 05:57

Code: Select all

if %random:~-1% LSS 5 (echo true) else (echo false)

Post Reply