XAccessor Reference

XAccessor is an AppleScript library to make followings possible.


use XAccessor : script "XAccessor"

set a_record to {a:"aa"}

script AScript
property a : "aa"
global b
on get_b()
return b
end get_b
end script

(*== Using Class Methods ==*)
(* access to property *)
log XAccessor's value_of(AScript, "a") -- "aa"
XAccessor's set_value(AScript, "a", "hello")

(* access to global variable *)
XAccessor's set_global("b", "hey")
log XAccessor's global_value("b") -- "hey"

(*== Using XAccessor Instance ==*)
(* access to property *)
set a_accessor to XAccessor's make_with("a")
log a_accessor's value_of(AScript) -- "hello"
log a_accessor's value_of(a_record) -- "aa"

(* access to global variable *)
set b_accessor to XAccessor's make_with("b")
log b_accessor's global_value() -- "hey"]


The mechanism of XAccessor is making script objects to access properties at runtime using "e;run script"e; command.

Class methods always generate an accessor object each time when called. The cost of generating an accessor object is expensive. The number of generating accessor objects should be keep minimum. Therefor it should be considered that storing accessor objects returned from make_with(a_name) into variables, and reuse it.

Class Methods


Obtain a value in a record or a property of a script object with specify its label of a text.


Set a value in a record or a property of a script object with specifying its label of a text.


Obtain a value of a global variable specified with a name.


set a value to a global variable specified with a name.

Obtain an Accessor Object


Obtain an accessor object to access a label specified with a text.

Instance Methods


get value in an_object


set a value to the property of given object


Get a value of a global variable


Set a value to global variable