Again, just adding to this slightly old thread with another option: Use QLimit() instead of QWrap() - you give that min and max values and it gives the min value if the input is lower than the min, and the max value if the input is higher than the max. Bear in mind it only works on quick type variables so feeding it longs might give you strange results.
Also, for the modulo function there is Frac() which returns the fractional part of a number. QFrac() can be used if the input is a quick type, and will execute quicker.
A full version of the original Blitz Basic 2.1 manual is available here:
http://www.amiblitz.de/content/blitz...mers/0001.html