/*This function is useful for randomly generated responses. It will call _rand() for a randomly generated number and then make sure that whatever _rand() returns isn't the same as the last two randomly generated numbers. This prevents the same response from being repeated several times in a row when the total number of responses available is small. Use it the same way you would use rand() or _rand(), just call it with a number argument. For instance if you want it to randomly generate a number between 1 and 10 then you would call it as srand(10); Code written by Daniel Freas I can be reached at erthwin@cox.net */ smallrand: object this = nil last = nil beforelast = nil ; srand: function(tot) { if( smallrand.this = nil ) { smallrand.this := _rand(tot); return smallrand.this; } else if( smallrand.last = nil ) { smallrand.last := smallrand.this; while( smallrand.this = smallrand.last ){smallrand.this := _rand(tot);} return smallrand.this; } else { smallrand.beforelast := smallrand.last; smallrand.last := smallrand.this; while( smallrand.this = smallrand.last or smallrand.this = smallrand.beforelast) { smallrand.this := _rand(tot);} return smallrand.this; } } ;