Posted by
Michael Ellis on
Jun 17, 2010; 1:11pm
URL: http://imagej.273.s1.nabble.com/Tracing-neurons-in-Sholl-analysis-tp3687379p3687384.html
Can anyone explain what I'm doing wrong regarding using the ImageJ
preferences?
After observing some strange behaviour I wrote this little
test plugin.
After setting a preference it then appears to fail to read it back.
The IJ_Prefs.txt file gets written correctly though.
I've tried deleting the IJ_Prefs.txt file (incase there was some weird
corruption). I'm running under OS-X with 10.5.8. I get the same result
with ImageJ and ImageJ64.
I must be doing something really silly, but I just cannot see it!
---------------------------------------------------------------------------
import ij.*;
import ij.plugin.*;
public class My_Plugin implements PlugIn {
public void run(String arg) {
IJ.log("IJ.getVersion()=" + IJ.getVersion());
final String prefName = "wacky.myval";
String prefValue = Prefs.getString(prefName, "Default Value");
IJ.log(String.format("pref '%s' is '%s'\n", prefName, prefValue));
prefValue = "New Value";
IJ.log(String.format("Setting pref '%s' to '%s'", prefName,
prefValue));
Prefs.set(prefName, prefValue);
Prefs.savePreferences();
prefValue = Prefs.getString(prefName, "A default value that should
not be seen!!!");
IJ.log(String.format("pref '%s' is '%s'\n", prefName, prefValue));
}
}
/*
--- Output -----------------------------
IJ.getVersion()=1.44c
pref 'wacky.myval' is 'Default Value'
Setting pref 'wacky.myval' to 'New Value'
pref 'wacky.myval' is 'A default value that should not be seen!!!'
------------------------------------------
After execution, the IJ_Prefs.txt file contains the line
.wacky.myval=NewValue
*/
Michael Ellis
Managing Director
Digital Scientific UK Ltd.
http://www.dsuk.co.uk[hidden email]
tel: +44(0)1223 329993
fax: +44(0)1223 370040
Sheraton House
Castle Park
Cambridge
CB3 0AX
The contents of this e-mail may be privileged and are confidential.
It may not be disclosed to or used by anyone other than the
addressee(s), nor copied in any way. If received in error, please
advise the sender and delete it from your system.