Preferred Multi-Platform Development Method

David Bovill david.bovill at gmail.com
Sat May 9 06:47:04 EDT 2009


I've got a similar function, which I've not got around to testing on Windows
and Linux yet. There are a few differences (like the use of baseconvert),
would be good to get it right?

function folder_Preferences
>     if the platform is "MacOS" then
>         return specialfolderpath("preferences") & "/"
>     else if the platform is "Win32" then
>         /*
>         CSIDL_APPDATA (FOLDERID_RoamingAppData)
>         version 4.71. The file system directory that serves as a common
> repository for application-specific data.
>         A typical path is C:\Documents and Settings\username\Application
> Data.
>         This CSIDL is supported by the redistributable Shfolder.dll for
> systems
>         that do not have the Microsoft internet Explorer 4.0 integrated
> shell installed.
>
>         CSIDL_LOCAL_APPDATA (FOLDERID_LocalAppData)
>         version 5.0. The file system directory that serves as a data
> repository for local (nonroaming) applications.
>         A typical path is C:\Documents and Settings\username\Local
> Settings\Application Data.
>
>         CSIDL_APPDATA (0x001a)
>         version 4.71. The file system directory that serves as a common
> repository for application-specific data.
>         A typical path is C:\Documents and Settings\username\Application
> Data.
>         This CSIDL is supported by the redistributable Shfolder.dll for
> systems that do not have the Microsoft internet Explorer 4.0 integrated
> shell installed.
>         */
>         put specialfolderpath(baseconvert("0x001a",16,10)) into
> preferenceFolder
>         return preferenceFolder & "/"
>     else
>         return $HOME & "/Documents/"    # somewhere better?
>         put specialfolderpath("Home") & "/.MyProgram/" into myPreferences
>     end if
> end folder_Preferences
>

2009/5/8 Derek Bump <userevolution at dreamscapesoftware.com>

> Hello David,
>
> I ran into the same problem with Preferences and the Registry when I
> started porting my software to Mac.  Since I fully intended to
> eventually port my software to Linux as well, I figured it would be a
> good idea to move away from using the Registry and any "system-specific"
> mechanisms.
>
> I accomplished this by creating a handler that loads a preferences
> stack, that is encrypted.  You can view the handler here...
>
>
>
> on doLoadPreferences
>   -- Save the Default Stack
>   put the defaultStack into cDefaultStack
>
>   -- Determine the Location of the Preferences based on the Operating
> System
>   if platform() = "MacOS" then
>      put specialFolderPath("Preferences") & "/MyProgram/" into
> myPreferences
>   else if platform() = "Win32" then
>      put specialFolderPath("0x001a") & "/MyProgram/" into myPreferences
>   else
>      put specialFolderPath("Home") & "/.MyProgram/" into myPreferences
>   end if
>
>   -- Create the Preferences File
>   if there is not a folder myPreferences then create folder myPreferences
>   put myPreferences & "Preferences.dss" into myPreferences
>   if there is not a file myPreferences then
>      create invisible stack "myPreferences"
>      set the password of stack "myPreferences" to "MyPassword"
>      save stack "myPreferences" as myPreferences
>   else
>      go invisible stack myPreferences
>   end if
>
>   -- Some Fine Tuning
>   hide stack "myPreferences"
>   set the passKey of stack "myPreferences" to "MyPassword"
>   set the defaultStack to cDefaultStack
> end doLoadPreferences
>
>
>
> The hander creates a preference "stack" if needed, and places it in the
> appropriate location for each operating system.  It also loads the
> Preferences stack into memory, and decrypts it so it can be modified.
>
> Then, I created my own versions of the queryRegistry() and getRegistry()
> functions...
>
>
>
> function doGetPref prefName
>   if there is a stack "myPreferences" then
>      put the prefName of stack "myPreferences" into theResult
>      return theResult
>   else
>      return "Error: Preferences Unavailable."
>   end if
> end doGetPref
>
> function doSetPref prefName,prefData
>   if there is a stack "myPreferences" then
>      set the prefName of stack "myPreferences" to prefData
>      save stack "myPreferences"
>      return empty
>   else
>      return "Error: Preferences Unavailable."
>   end if
> end doSetPref
>
>
>
> This allowed me to stop using the Windows Registry completely, and also
> created a fully functional mechanism for creating a Preference file on
> any system.
>
>
> Derek Bump
> Dreamscape Software
> http://www.dreamscapesoftware.com
>
> ___________________________________________________________________
> Compress your photos quickly and easily with JPEGCompress 2.9!
> http://www.dreamscapesoftware.com/products/jpegcompress/
>
>
> David Beck wrote:
> >
> > We are just starting to play around with building stacks for the Mac. We
> > have concentrated exclusively on Windows in the past since that is where
> > the majority of our user base is. However, I have had many requests for
> > a Mac version of the volunteer scheduling software we produce.
> >
> > I can't believe how easy it looks like it will be to migrate to Mac. I
> > tried it the other day and everything just works! It is incredible.
> > Working with Rev just keeps getting better and better!
> >
> > My only question is where to store the preferences that we are storing
> > in the Windows Registry. We do have a mechanism to store preferences,
> > but there are certain preferences that are system wide, and should not
> > change based on the user of the computer (e.g. the install path of a
> > standalone application, etc.). Any advice on where to store these global
> > system-wide preferences on the Mac?
> >
> > Richard, I understand you are using a stackfile for preferences. How
> > exactly do you implement this? That is, what calls do you use to get and
> > set preferences in the stackfile? Does the folder you mentioned
> > (specialApplicationFolder("preferences")) change based on the current
> > user or is it system wide? Also, are there any permissions issues to be
> > careful about?
> >
> > Thanks very much in advance for any guidance!
> >
> > --
> > David Beck
> > Rotunda Software
> > www.ministryschedulerpro.com
> >
> > _______________________________________________
> > use-revolution mailing list
> > use-revolution at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> > subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-revolution
> >
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



More information about the use-livecode mailing list