PDA

View Full Version : do { ask question } while (I'm being lame);


lardlad
05-08-2006, 10:04 PM
This little chunk of code is sending me (and Maya) into a non-exiting loop. What am I doing wrong here?
<snip>
int $oldVect=0;
int $newVect=0;
do {
int $newVect=floor(rand(2)+.5);
print($oldVect+","+$newVect+"\n");
} while($oldVect==$newVect);
</snip>
I just want to assign $newVect one of three random integers that is not already assigned to $oldVect. As Maya dies, it prints out a list of both values - they are frequently not equal, but the loop doesn't exit.

Thanks greatly, sorry for what I bet is a truly idiotic question - I tried searching cgtalk, but "do" and "while" are apparently common words and can't be included in a search list.

Blot12345
05-08-2006, 10:45 PM
well im just getting into MEL myself, but I've had quite a bit of programming experience and the only thing that might fix it would be to remove the int on the second $newVect. I can't check to see if that matters but its worth a shot.
int $oldVect=0;
int $newVect=0;
do {

REMOVE THIS --> int <-- $newVect=floor(rand(2)+.5);

print($oldVect+","+$newVect+"\n");
} while($oldVect==$newVect);

lardlad
05-08-2006, 11:24 PM
Yep! Thanks. I decided to be fancy because rand() returns a float. EBKAC! Thanks again.

CGTalk Moderation
05-08-2006, 11:24 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.