My Favorite Object: jstrigger
Granted, the object isn’t going to solve all of your problems, but I’ve found it incredibly useful for doing things that would otherwise be cumbersome with other objects or to avoid the somewhat drawn out process that is required for setting up a new js object and script.
- Download the patches used in this tutorial.
Each parentheses pair describes an outlet, and whatever is within that parentheses specifies how the data is evaluated and processed. In this example, we have three different instructions, output each to different outlets – this is an exceptionally simple example, and only hints at the true potential of the object.
The ‘a’ refers to the incoming list, and the  and  refer to the position of a value in the list. The first value is a
min and the second value is a
You can make this as complicated as you want, adding various other Math functions or logic to fine-tune to your specific needs. It all happens in one box, so it is very portable and fairly easy to read. Here is an example of prepending a string to the output:
I’m simply making an array out of the entire statement, with the first entry being my ‘freq’ string, and the second entry being the random value.
Most any of the global Math functions will work in this manner. For a list, check out MDN.
Here is a simple example that removes spaces from incoming data:
Again, we treat the incoming text like the first element of the array, a, and then use the
replace() function to look for the spaces (s), and then replace them with nothing (‘’).
Another feature that I love is the ability to use conditional operators as shorthand for
Conditional (or ternary) operators evaluate a condition that return ‘true’ or ‘false’ (does the input match ‘bob’?), and then returns an expression based on what is returned. In this case, if it (a == ‘bob’) is true, “bob has entered” is returned, and if it is not, “someone else has entered” is returned.
I’m just scratching the surface here, as you could do a whole lot more, but hopefully this at least shines a light on a dimly lit corner of Max that you might find useful in your patching. Enjoy!