We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Export Application w/ its own preferences file
Page Index Toggle Pages: 1
Export Application w/ its own preferences file (Read 899 times)
Export Application w/ its own preferences file
Feb 27th, 2007, 11:04pm
 
Hey everyone,
Maybe someone can help me out here.  I am writing a screensaver-like sketch with the hope of using it as a fullscreen OSX application when complete.  Currently, i have created a preferences.txt file that lives in the sketch data folder.  This file is loaded with loadStrings() and sets some parameters for the sketch when it is ran.  While the app is running i give the user ability to change some of these parameters to achieve the final look they want and then save the preferences.txt file back out, so that next time it is launched it looks the way they like it.  I saved the file with the saveStrings("data/preferences.txt") command.  However, the problem is going to be when i export the final OSX app where i cannot read and write to the same file due to the fact that the data folder is inside the .jar file.  Basically, i just need the final OSX app to have its own readable/writable preference file.

Any suggestions?

-erick
Re: Export Application w/ its own preferences file
Reply #1 - Feb 28th, 2007, 12:21am
 
How about, load the defaults from preferences.txt and then save them to userprefs.txt if it doesn't exist. From then on, if userprefs.txt exists, load the preferences from there instead.
Re: Export Application w/ its own preferences file
Reply #2 - Mar 1st, 2007, 4:19pm
 
Based on what i know about the loadStrings() command, you can only load from a file located in the data folder, or from a url.  Thats seems to create another problem.
Re: Export Application w/ its own preferences file
Reply #3 - Mar 1st, 2007, 4:41pm
 
that's not true. i think the reference is misleading there ...
you can load any file by passing in the path.

F
Re: Export Application w/ its own preferences file
Reply #4 - Mar 9th, 2007, 12:11am
 
When you export your application, can't you just create a new data folder with preferences.txt in it, and then put the exe and datafolder in the same folder?
Re: Export Application w/ its own preferences file
Reply #5 - Mar 9th, 2007, 5:01pm
 
you should be able to do that with a data folder near your application. you'd have to try different things to see where it needs to be located for osx (whether next to the .app or somewhere inside the package contents).

you can also specify absolute paths, or have the user select it, but that's not very cross platform.

there's also the java preferences api:
http://java.sun.com/j2se/1.4.2/docs/guide/lang/preferences.html
if you want to go the java route.
Page Index Toggle Pages: 1