Use HTTPS links where feasible
= Functions =
Most of the time, you will call ''functions'' which implement the actions you want to execute. Functions have names, like variables, but they also have ''parameters'' that you can pass to the functions. ImageJ comes with many [
http://imagej.net/developer/macro/functions.html predefined functions] that you can call to perform specific calculations or other operations.
This example writes ''Hello, World!'' to the ''Log'' window:
= Installing macros =
To install keyboard shortcuts or tool icons, you need to [
http://imagej.net/developer/macro/macros.html#tools wrap macro code in ''macro'' blocks]:
The icon is defined by a funny-looking string (in this case, ''C000R11ee''). To learn how to define your own icon, please have a look [
Many tools open an option dialog upon double-click on the icon. You can do that, too, by choosing a name that ends in ''Action Tool Options'':
== More example macros ==
There are quite a lot of macros on the [
http://imagej.net/macros/ ImageJ website], and specifically [ http://imagej.net/macros/examples/ example macros] including a few from the Macro workshop at the [http://imagejconf.tudor.lu/archive/imagej-user-and-developer-conference-2010 ImageJ conference 2010]. Since there is no categorized index, you might want to use the search facility on [ http://imagej.net/developer/index.html this page].
= Overcoming limitations =
== Macro extensions ==
It is possible to implement code in [[Java]] which extends the macro language via the [
http://imagej.net/developer/macro/functions.html#Ext <code>Ext</code> prefix]. However, this cannot be done within the macro itself.
== The call function ==
http://imagej.net/developer/macro/functions.html#call <code>call</code> function] can invoke Java methods directly. However, this function only supports calling <code>public static</code> Java methods which accept <code>String</code> only, and return <code>String</code> only. Most times, though, the needed function does not conform to these requirements; this approach is suitable mostly for routines designed to be called from the macro language in this way.
== The eval function ==
Here is an example which sets the position of a [[3D Viewer]] window:
= Further documentation =
A complete description of the macro language, a reference of the built-in functions, and examples can be found [