My scenario is that I have a set of scripts containing sub routines, and then “main” scripts that call the sub routines in various orders. I would like to create a settings file, that basically contains global variables that can be used across all scripts, as I run the “Main” script. or example, several sub routines across various script files might use the same login name, but I would like the ability to change the login name in one location, instead of having to edit many files for each execution.
Has anyone encountered this issue, and found a decent method to solve it?
property preffile : "com.companyname.productname" --this is what i do
--then i have a name for each individual preference
--eg:
try
display dialog "I want " & ReadaPref(preffile, "dog count") & " dog(s)!"
on error
set dcd to text returned of (display dialog "how many dogs do you want?" default answer "101")
WriteaPref(preffile, "dog count", dcd)
end try
--subroutines for prefs
on WriteaPref(preffile, prefname, prefValue)
tell application "Finder"
set prefvals to do shell script ("defaults write " & preffile & " '" & prefname & "' '" & prefValue & "'")
end tell
end WriteaPref
on ReadaPref(preffile, prefname)
tell application "Finder"
set prefvals to do shell script ("defaults read '" & preffile & "' '" & prefname & "'")
end tell
return prefvals
end ReadaPref