Posted by
Matti Christoph on
URL: http://imagej.273.s1.nabble.com/retrieve-variables-from-txt-file-and-run-command-tp5021572.html
Dear all,
I have a macro, helping to annotate images with scale bar, channel
names, doing a montage and so on. So far, the initial dialogue gives the
user several options, and is filled with default values.
I like to have a text file with those variables and recall them
automatically when the Macro is started, and yes, that works.
setOption("ExpandableArrays", true);
mp = getDirectory("macros");
pathset = mp+"CnZsettings.txt";
string2 = newArray();
file = File.openAsRawString(pathset);
delimiter= '\n';
string2 = replace(file, delimiter, "@");
values = newArray();
values = split(string2, "@");
However, when taking the value from the text file (e.g. Green) and
assigning to a variable:
a=values[0];
the run(a); or SetColor(a); to change either the channel colour or the
foreground colour don't work, giving me /Unrecognised command: "Green"/.
Retrieving however numerical values from the same .txt file and using
them e.g. for the scale bar do work.
Do you have any suggestion where to look for a solution? I believe that
I somehow have to change the "type" of the variable or something?
I already tried a="\""+values[0]+"\""; but this didn't work, giving me
/Unrecognised command: ""Green""/.
I am very happy if one of you could help me.
Best,
Chris
--
Signature
Christoph Matti
Biotechnologie Institut Thurgau an der Universität Konstanz
Unterseestr. 47
CH - 8280 Kreuzlingen
T: +41 71 6785022
E:
[hidden email] <mailto:
[hidden email]>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html