+1 on Steve's _MEM comment, and he is the _MEM guru here...
I particularly like it for manipulating all sorts of arrays; integers, longs, fixed length strings, UDTs, etc.
BTW, here is how I generally approach integer value limiting.
I particularly like it for manipulating all sorts of arrays; integers, longs, fixed length strings, UDTs, etc.
BTW, here is how I generally approach integer value limiting.
Code: (Select All)
'Limit an integer argument to a maximum value
FUNCTION MaxOf% (value AS INTEGER, max AS INTEGER)
MaxOf% = -value * (value <= max) - max * (value > max)
END FUNCTION 'MaxOf%
'Limit an integer argument to a minimum value
FUNCTION MinOf% (value AS INTEGER, minimum AS INTEGER)
MinOf% = -value * (value >= minimum) - minimum * (value < minimum)
END FUNCTION 'MinOf%
'Limit an integer argument between minimum and maximum bounds
FUNCTION MinMax% (value AS INTEGER, min AS INTEGER, max AS INTEGER)
MinMax% = MaxOf%(MinOf%(value, min), max)
END FUNCTION 'MinMax%
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
sha_na_na_na_na_na_na_na_na_na: