I have set of script applications which together define an overall application. In other words, there is one main application which interacts with the user and spawns off several sub-applications (stay-open) which essentially run in the background until the main app is finished, then they are all told to quit.
I have a dozen or so constants I wish to share among the main script and all sub-scripts. In a former life, this was done for example with “header files” and #include statements. This allowed a set of variables/constants to be set in one file that could be included in all others that needed to use them. In other words, if any of these constants change, it would be more optimal to change them in one file instead of every script file.
For example:
– Shared Constants
set MainCity to “Boston”
set numCities to 10
set numRoads to 5
set numCars to 50
– end
I want to put these MainCity, numCities, etc. in one place to be shared by several scripts. Is that a “script library”? Or what?
-- constants.scpt
on getConstants()
set constantsDictionary to {mainCity:"Boston", numCities:"10"}
return constantsDictionary
end getConstants
Reading from another file:
set included to load script ("Macintosh HD:Users:kmitko:Desktop:constants.scpt" as alias)
tell included to set mainCity to (get mainCity of getConstants())
mainCity