ID:257765
 
//Title: "Clip"
//Credit to: Xx Dark Wizard xX
//Contributed by: Xx Dark Wizard xX

/*
Returns a value between the mininum and maximum values.
*/


proc
Clip(value,min,max)
if(!value || !isnum(value)) return
return min(max(value,min),max)
See also [link] for the Bound Constraint snippet, which is an inline version of the same procedure that uses the ternary operator "?:" instead of the built-in procedures min() and max().