ini file question on the Mac

Jan Schenkel janschenkel at yahoo.com
Mon Aug 11 14:15:49 EDT 2008


--- mfstuart <mfstuart at cox.net> wrote:
> 
> Hi all,
> 
> Please excuse my Mac ignorance as I'm a totally
> Windows guy, but...
> 
> As is an ini file for a Windows application, so is a
> ??? file on the Mac OS.
> Could someone help me by "filling in" the ??? blank
> for the Mac OS?
> 
> Regards,
> Mark Stuart
> 

Hi Mark,

To find the proper place to store your preferences
file on MacOSX, use the 'specialFolderPath' function:
##
put specialFolderPath("preferences") into
tPreferencesDirectory
##

While most MacOSX applications will store their
preferences in a .plist XML structure, you're not
bound to this convention, and can just use the same
.INI structure if you like.

If you decide to go the 'plist' route, check out the
'defaults' command line tool, which you can use via
the 'shell' function. Here's a read/write pair that
I've used in the past:
##
on MacOSX_WritePreference pKey, pValue
  put "defaults write com.companyname.appname" && \
      quote & pKey & quote && \
      "'" & pValue & "'" \
      into tShellCommand
  get shell(tShellCommand)
end MacOSX_WritePreference

function MacOSX_ReadPreference pKey
  put "defaults read com.companyname.appname" && \
      quote & pKey & quote\
      into tShellCommand
  return shell(tShellCommand)
end MacOSX_ReadPreference
##

For more information on the 'defaults' command-line
tool, see:
<http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/defaults.1.html>

Oh, and just in case you're wondering where to store
preferences on other platforms:

- on Linux, the consensus seems to be to store the
data in a subdirectory of the user's home directory -
which you can get as specialFolderPath("Home").

- on Windows, you would store the preferences data in
your own subdirectory of the user's application data
folder - which you can get as specialFolderPath(26) ;
if the preferences should be shared by all users, use
the 'All Users' application data folder - which you
can get as specialFolderPath(35).

For extensive information on the specialFolderPath
function, and which special codes you can use on which
platform, here's the excellent tip from Ken Ray:
<http://www.sonsothunder.com/devres/revolution/tips/file010.htm>

Hope this helped,

Jan Schenkel.

Quartam Reports & PDF Library for Revolution
<http://www.quartam.com>

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


      



More information about the use-livecode mailing list