http://imagej.273.s1.nabble.com/Re-How-to-save-macro-variables-values-in-a-text-file-tp5001804p5001806.html
> Hi Thomas,
>
> > I would like to record the values entered by the user into a file
> > (typically a text file), so that the next time the macro is used the
> > default values will be the one entered before (rather than the
> > "factory settings").
>
> You can accomplish your goal using the ij.Prefs class, specifically the
> Prefs.get and Prefs.set methods. These methods allow you to store settings
> into the ImageJ preferences cache on disk for later retrieval, which sounds
> like what you need.
>
> From a macro, the following should work (though I did not test):
>
> call("ij.Prefs.set", "myVariableKey", "desiredValueToSave");
> previousValue = call("ij.Prefs.get", "myVariableKey", "defaultValue");
>
> Be sure to choose a unique variable key to avoid potential name clashes
> with other plugins & macros.
>
> Regards,
> Curtis
>
>
> On Mon, Feb 18, 2013 at 3:30 PM, TL <
[hidden email]> wrote:
>
> > Dear ImageJ users,
> >
> > I apologize if this question is already documented, I could not find
> > anything on the internet.
> >
> > I am writing a macro which starts with a dialog box, allowing to set
> string
> > variables. I would like to record the values entered by the user into a
> > file (typically a text file), so that the next time the macro is used the
> > default values will be the one entered before (rather than the "factory
> > settings").
> >
> > I can easily read variables values from a text file by using a function
> > like this one...
> >
> > function getValues() {
> > dataString=File.openAsString(initializationFilePath);
> > rows=split(dataString, "\n");
> > variable_1=rows[0];
> > variable_2=rows[1];
> > }
> >
> > ...but I am unable to "update" the values in the text file, or even to
> > overwrite it.
> >
> > Could you please give me some clues on how to do that?
> >
> > Sincerely,
> > Thomas
> >
> > PS: sorry for double-posting, the first message was inadvertently sent!
> >
> > --
> > ImageJ mailing list:
http://imagej.nih.gov/ij/list.html> >
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>