Home > XModules >

Requirements

  • OS X 10.9 or later
    • Developed and tested on OS X 10.14.6.

Download

Version 1.0.2 -- 2020-02-05

Dependencies

XPreferences

XPreferences is a AppleScript Library to help saving and loading settings(preferences) of AppleScript applications.

Because AppleScript applications (droplets, applets and script files) can keep values in properties after the termination of the execution, properties can be used to store settings. But values of properties will be initialized when the script is recompiled to fix bugs or to implement new functions.

Therefore, even in the case of AppleScript, it is useful to save settings in an external file.

XPreferences help to load and save a user defined script object to store settings (preferences script object) into "~/Library/Preferences" folder.

Also XPreferences support to update the preferences script object. When your AppleScript application is updated and the specification of the preferences script object is changed, XPreferences help to move values from old preferences script object to new one.

(* A sample script of XPreferences. *)
use scripting additions
use XPreferences : script "XPreferences"

on setup()
script XPreferencesSampleSettings
property parent : AppleScript -- reduce size of the preferences file.
property version : "1.0" -- optional
property _msg : "hello"

on message()
return my _msg
end message

on set_message(v)
set my _msg to v
return me
end set_message

on update(old_settings) -- optional
set my _msg to old_settings's _msg
end update
end script

tell XPreferences
set_default_prefs(XPreferencesSampleSettings)
end tell
end setup

on run
setup()
set prefs to XPreferences's load()
display alert (prefs's message())
prefs's set_message("Hi")
XPreferences's save_current_prefs()
end run

History

  • 1.0.2 -- 2020-02-05
    • OpenHelpBook.scptd is used to display a help book instead of HelpBook.osax.
    • Fixed : prefs handler did not work.
    • Many fixes.
  • 1.0.1 -- 2018-07-20
    • Fixed example script.
      • If ModuleLoader is not utilized, default preferences script must be set at the launch time.
      • Definition of the default preferences script contirubutes small size of the preferences file.
  • 1.0 -- 2018-07-13
    • First release.