Posted by
Andy Weller on
Aug 02, 2006; 2:21pm
URL: http://imagej.273.s1.nabble.com/User-defined-functions-tp3701916p3701917.html
I have a user-defined function that does various measurements:
function measurements() {
some measurements
...
out = "";
out = Name + "," + area + "," + ...; // String container for all results
return out;
}
Now in my main macro it states that "out" is an "undefined variable",
although I am returning it from function measurements()?!
macro "Test" {
dir1 = getDirectory("Choose Source Directory");
list = getFileList(dir1);
numberFile = list.length;
setBatchMode(true);
compResults = newArray(numberFile);
for (i=0; i<numberFile; i++) {
some stuff
...
measurements();
compResults[i] = out; // THIS IS WHERE IT BUMS OUT?!
}
Any clues out there?!
Thanks, Andy
On Wed, 2006-08-02 at 14:04 +0200, Andy Weller wrote:
> Dear all,
>
> I have built up a rather lengthy macro and am splitting it up into
> discrete user-defined functions for debugging simplicity.
>
> I think I understand how to operate them (from:
>
http://rsb.info.nih.gov/ij/developer/macro/macros.html#functions); can
> someone explain to me if I have the wrong idea please (regarding passing
> things to/from them really)?
>
> macro "Test" {
> open();
> img = getImageID();
> setAutoThreshold();
> run("Analyze Particles...", "size=5000-Infinity circularity=0.00-1.00
> show=Masks exclude clear include");
> mask = getImageID;
> myfunction(img, mask); // Passes img and mask to function "myfunction"
> }
>
> function myfunction(img, mask) { // img and mask passed to "myfunction"
> some measurements on img and mask
> return results; // "results" returned to macro "Test"
> }
>
> Thanks, Andy