Page 1 of 1

Doing a random true/false =FIXED=

Posted: 20 Nov 2010 12:29
by Azrooh
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

Re: Doing a random true/false =FIXED=

Posted: 21 Nov 2010 05:41
by jeb
Hi Azrooh,

this should work

Code: Select all

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


hope it helps

Re: Doing a random true/false =FIXED=

Posted: 21 Nov 2010 05:57
by !k

Code: Select all

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