Hello again!
I’m a bit stuck. I’d like to know how to clean up my code!
I have the following:
on writeDefaults()
log "Writing to defaults file..."
writeDefault("storeNumber", storeNumber, "string")
writeDefault("timeZone", timeZone, "string")
writeDefault("startTime", startTime, "string")
writeDefault("shutTime", shutTime, "string")
writeDefault("remoteLogin", remoteLogin, "bool")
writeDefault("remoteDesktop", remoteDesktop, "bool")
writeDefault("softwareCheck", softwareCheck, "bool")
writeDefault("timeMachine", timeMachine, "bool")
writeDefault("tmSource", tmSource, "bool")
writeDefault("screenSaver", screenSaver, "bool")
writeDefault("desktopButtons", desktopButtons, "bool")
writeDefault("deepFreeze", deepFreeze, "bool")
writeDefault("pathtoPPD", pathtoPPD, "bool")
end writeDefaults
on writeDefault(setDomain, setKey, valueType)
do shell script "defaults write " & ((POSIX path of (path to me)) & "Contents/Resources/com.apple.visuals") & space & setDomain & " -" & valueType & space & setKey
end writeDefault
I’d like to make this a much shorter piece of code by creating an array of all of the items I have it run with. Something that would simply run a piece of code for every entry in an array, get the values from that array, and run it. The idea is that I could have one variable that listed all of the GUI elements I’d like checked, and I can add or remove entires from there and later on when a handler is called it would automatically run the added entires.
The problem is I need a value to be stored with it’s associated values, such as the key, value, and then type (string, int, or boolean.)
Any ideas would be wonderful!
Thanks!