This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

different [rand values] (SOLVED)

Help for those learning Tcl or writing their own scripts.
Post Reply
T
Torrevado
Op
Posts: 101
Joined: Wed Aug 02, 2006 6:29 pm

different [rand values] (SOLVED)

Post by Torrevado »

Hello,

I'd like to know how to get two different random values. Value 1 + Value 2 *must* be = 100

I tried

Code: Select all

set value1 [rand 100]
set value2 [rand 100]
Obviously doing addition of both values, the result can be less than 100 or upto 200.
Last edited by Torrevado on Sun Aug 22, 2010 1:46 pm, edited 1 time in total.
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Re: different [rand values]

Post by willyw »

Torrevado wrote:Hello,

I'd like to know how to get two different random values. Value 1 + Value 2 *must* be = 100

I tried

Code: Select all

set value1 [rand 100]
set value2 [rand 100]
Obviously doing addition of both values, the result can be less than 100 or upto 200.
How about :

Code: Select all

set value2 [expr 100 - $value1]
T
Torrevado
Op
Posts: 101
Joined: Wed Aug 02, 2006 6:29 pm

Post by Torrevado »

Yeah, that is.
Thank you very much :wink:
Post Reply