Defining functions
A function is a piece of code that does a very specific operation. Defining functions in the ImageJ macro language is simple. You just need to use the function
keyword, followed by the function name. A function may receive as many arguments as desired and may or may not return a value. Consider the following function:
functiongetMax(a, b) { if (a > b) { return a; } else{ return b; } } print(getMax(5, 4)); print(getMax(5, 6));
As you can see from the previous example, the function definition does nothing by itself. In order to execute it, it needs to be called.