gettingstarted
[Top] [All Lists]

Re: Cross Platform Preference File

To: ascii at 1st dot net, Getting Started <gettingstarted at lists dot realsoftware dot com>
Subject: Re: Cross Platform Preference File
From: Ian Mann <ian at ianmann dot demon dot co dot uk>
Date: Sun, 30 May 2004 07:59:13 +0100
Cc:
Delivered-to: gettingstarted at lists dot realsoftware dot com
List-help: <mailto:gettingstarted-request@lists.realsoftware.com?subject=help>
List-id: Getting Started <gettingstarted.lists.realsoftware.com>
List-post: <mailto:gettingstarted@lists.realsoftware.com>

On Sunday, May 30, 2004, at 04:15  am, Jay Rimalrick wrote:

I'm sorry I was not more clear, my question about a cross platform preference file was more concerned with the file path. I'm not sure if I am going to make an installer for my program, if I was i would simply put it in the folder that my program was created in. However, if I let the user drag the program where they like, they may put it on their desktop and then the preference file would
be on the desktop.

I know the mac keeps preference files in the preferences folder. However I don't really know where windows standardly keeps their preference files. I don't think there is a place. I was just wondering if realbasic offered a simply
way to write preference files in a standard place despite the platform.

Thanks for any input,
Jay



You may not want to ship with a preference file : You could :

set up all your prefences as properties in your app.

On start up look for the preferences file in your app : (In the App open event)

  dim f as folderItem
  dim t as textInputStream
  dim a as String
  f = preferencesFolder.child(PrefFileName)
  if f <> nil then
    if f.exists then
      t = f.openAsTextFile
      if t <> nil then
'Read Prefs here ( UserName = t.readLine) etc
else
defaultPrefs
end if
else
defaultPrefs
end if
else
defaultPrefs
end if

So if you cant find/read the prefs file you set them to defaults.

UserName = "Archibald P Finkelstein"

The in your app close event you can have

  dim f as folderItem
  dim t as textoutputStream
  f = preferencesFolder.child(PrefFileName)
  if f <> nil then
    t = f.createtextFile
    if t <> nil then
etc (t.writeLine UserName)

plus all associated end ifs.

You basically need three methods :

ReadPrefs (Open)
DefaultPrefs (If read prefs doesn't work)
WritePrefs (Close)

Good Luck and Best Regards

Ian


_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>