OK, this tip is about using switch(), it can be very useful when error checking, often a single switch() can catch all the errors in a command.

This example checks to make sure %0 is between 1 and 10, and that %1 is not in v(TEST).

switch(0,
  <[lt(%0,1)],Less than 1,
  [lte(%0,10)],Not less than or equal to 10(greater than 10).,
  <[match(v(TEST),%1)], %1 is in the list.,
 Do the code.
)
See this code lets you match on boolean values, if you want to match on 0, you just put the code in as is, if you want to match on 1 or higher, you just put a < in front. The 1 or higher feature is especially useful in lists.

There is another way of using switch and that's to put multiple values in the first argument like %qA|%qB, and then match like 0|*, or 1|1, etc. Which I used to use, now I tend to prefer the first method I showed you.
I hope I was able to write this clear enough, if you have any questions or ideas of how to improve this tip, let me know.
Back