Mark, many thanks for providing this very useful tool.
Iād like to give back, or maybe give forward, a little, so Iāve cleaned up the text at https://latenightsw.com/support/freeware/list-record-tools/, and have it available below as an example script:
LNSOSAX List & Record Commands Examples
Mostly the text from the above reference, but any errors are mine.
(*
REF: https://latenightsw.com/support/freeware/list-record-tools/
*)
use scripting additions
use application "LNSOSAX"
(*
The following are some brief examples illustrating how the List & Record Tools in the LNSOSAX.app that can be used.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Record Processing
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
One of AppleScriptās major limitations is that it cannot dynamically access items in records
ā record keys must be known at compile time.
The List & Record Tools commands provides a series of commands for accessing records in a dynamic fashion.
AppleScript records can contain properties and user properties.
A property is defined by an application through
its dictionary and is represented internally via a 4-character code.
For example, name is a term defined by AppleScript and many applications.
The code {name:"Mark"} creates a record containing a property with the 4-character code āpnamā
and the value "Mark".
A user property is defined within AppleScript.
The term myAge is not defined in any dictionary and creates a user property when used in a record:
(e.g. {myAge:42}).
NOTE: On Mac OS X systems prior to 10.6, AppleScript converts user property names to lower case, unless the |Name| notation is used. Because of this, user property names must be given in lowercase on pre-10.6 systems.
Accessing Properties
4 commands are provided for working with properties:
get, set, or delete properties in a record,
get the 4-character IDs of all the properties in a record:
*)
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
get property "pnam" in {name:"Mark"}
--> "Mark"
set property "pnam" in {name:"Mark"} to "Gerry"
--> {name:"Gerry"}
delete property "pnam" in {name:"Mark"}
--> {}
get property IDs {name:"Mark"}
--> {"pnam"}
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(*
Accessing User Properties
4 commands are provided for working with user properties:
get, set, or delete user properties in a record, and
get the names of all the user properties in a record.
*)
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
get user property "myAge" in {myAge:42}
--> 42
set user property "myAge" in {myAge:42} to 28
--> {myAge:28}
delete user property "myAge" in {myAge:42}
--> {}
get user property names {myAge:42}
--> {"myAge"}
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
List Processing
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The List & Record Tools scripting addition provides three commands for treating AppleScript lists as sets. These commands were originally part of the now discontinued LNS Scripting Additions. We have received frequent requests to provide them for Mac OS X.
Set Intersection (return all items that are common to two lists)
Hereās an example involving integers where the command returns only those integer values common to both lists:
*)
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
intersection of {1, 2, 3} and {2, 3, 4}
-->{2, 3}
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(*
This command can handle other data types such as strings, dates, etc. For strings, it honours AppleScriptās considering case, whitespace, hyphenation.
Set Difference (return items that are not common to two lists)
Hereās an example involving integers where the command returns only those values that are not common to both lists:
*)
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
difference of {1, 2, 3} and {2, 3, 4}
-->{1, 4}
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(*
This command can handle other data types such as strings, dates, etc. For strings, it honours AppleScriptās considering case, whitespace, hyphenation.
Set Union (return all unique items from both lists)
Hereās a simple example involving numbers where the command returns unique values from both lists:
*)
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
union of {1, 2, 3} and {2, 3, 4}
-->{1, 2, 3, 4}
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(*
Hereās another example involving numbers, booleans, and strings:
*)
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
union of {1, 2, true, "Hello", 3, 4} and {false, 2, "Hello", "Mark", 10}
-->{ "Hello", "Mark", false, 1, 2, 3, 4, 10, true }
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(*
Like the intersection and difference commands, this command honours AppleScriptās considering case, whitespace, hyphenation.
*)