Posted by
Joachim Wesner on
URL: http://imagej.273.s1.nabble.com/macro-creating-n-Arrays-within-a-for-loop-tp3688201p3688205.html
Hi Cristophe,
yep, you are right, but I fear, this feature alone would still make any
code very clumsy,
what one would really need is some kind "indirection" that really takes a
string
variable and interprets it´s contents in the same places (within an
expression
and also to the left of the assignment) and the same way as the variable
that´s
"in" the string (including indexing... etc.)
Joachim
ImageJ Interest Group <
[hidden email]> schrieb am 07.05.2010 13:57:43:
> I think there is an "execute" command in the macro language that reads
> a string as a command. It is the "eval" function :
>
> eval(macro)
> Evaluates (runs) one or more lines of macro code. An optional second
> argument can be used to pass a string to the macro being evaluated.
> See also: EvalDemo macro and runMacro function.
>
>
http://rsbweb.nih.gov/ij/developer/macro/functions.html#eval>
> Or maybe I make a confusion ? I used it recently to create a segmented
> line from an array of coordinates, by concatenating a MakeLine command
> with all coordinates as a string, and using "eval" to execute it.
>
> Christophe
>
> On Fri, May 7, 2010 at 13:20, Joachim Wesner
> <
[hidden email]> wrote:
> >>> name = "test " +i;
> >>> name = newArray(k);
> >
> >>Maybe because you are trying to make a variable name that contains a
> > space.
> >>Try removing it.
> >
> > No, this will only create a new Variable called "name" of type Array,
the
> > old string variable "name" will be discarded!
> >
> > As long as there is no "execute" statement in the ImageJ Macro language
> > (Hint! Hint!), that really RE-interprets a string as a new command
> > (however, if I´m not mistaken here, you would need thsi also in all
places,
> > where you need to access one the the multiple arrays,
> > not only when creating those) you are somewhere out of luck.
> >
> > Johannes,
> >
> > What I would do in such cases, if you already know the number of
"arrays" n
> > outside the loop (can still be a dynamic value that is read from
> > somewhere on runtime, you could create an array of n-times the single
size
> > and use a variable offset in that array.
> >
> > (Maybe this is basically what you did?)
> >
> >
> > Cheers
> >
> > Joachim Wesner
> >
> >
> >
> > ______________________________________________________________________
> > This email has been scanned by the MessageLabs Email Security System.
> > For more information please visit
http://www.messagelabs.com/email> > ______________________________________________________________________
> >
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit
http://www.messagelabs.com/email
______________________________________________________________________