Back in my cryptography threads I wrote my own random number generator because the trouble with %random% is that it cannot be directly seeded. Sure, people like Dave have gone to great lengths to explain how %random% derives it's seed based on the system clock, etc. but if you can't force it to use a specific seed value it's of no use for predictable number stream generation.
In any case, here's the link to my random function, or at least the version of it that existed back then:
viewtopic.php?p=27666#p27666. I know for sure I "macro-ized" it since then, but I don't have that code handy and I don't know what else I might have done to it to improve it. I know at least one old version of my random function had issues occasionally spitting out negative numbers as well, so you might want to beware of that in case it's this version
Also I feel I have to repeat that even while I used this function in my threads for demonstrating cryptographic purposes, this is *NOT* in any way a cryptographically secure PRNG.
As far as usage, it's intended to be used with two (optional) parameters, a range and a seed value. The range is formatted as a min and max value separated by a hyphen, ie "0-100", within the bounds of 0-32767. The seed is any integer, and as stated previously in this thread, given the same seed the random number will always turn out the same. If 'rand 0-10 12345' spits out a 7, it will always spit out a 7, no matter how many times you call it or what time of day
If you don't care about seeding it, leave that parameter out and the function defaults to using %random%.
In addition to spitting out the random number, if an input seed is provided, the function also returns the next seed in the generation sequence, so you can use it to generate long streams of repeatable random numbers. You'll find plenty of usage examples in that cryptography thread if the seeding concept is of interest to you.