Your subroutines and load scripts

When i saw that aaon has lots of own “load scripts” in this page: How can i bundle my scripts into my script? http://macscripter.net/viewtopic.php?id=34379

i got idea that programmers who been programming for long time propably have lots of own “load script” and “subroutines” which could be really good learning resource for newbie programmers.

So is anybody willing to share their “load scripts” and “subroutines” and uploading them to here Coding Exchange or somewhere else?

For instance now i would like to create “load script” or “subroutine” which is similar to this code below, but it would also add and delete preferences and also support arrays and dictionaries, kind of folders.

From http://lists.apple.com/archives/applescript-users/2009/Aug/msg00206.html

Each property list item can also contain other property list items. In your example,
you are using the value of one property list item (a record) as the key for getting
another property list item. You just need to break down each key/subitem - I use
a list of items to build a reference to the desired property list element:

to GetPlistElement from PlistItems
	(*
	get the specified element from a simple Plist structure by name or index
	note that the indexes are not necessarily the order shown in the XML file (?!)
    	the number of items is not fixed, but must be at least 2 (the Plist file and a Plist element)
 		parameters:		PlistItems [list] -
							item 1 [mixed]: the Plist file path (Finder or POSIX)
							item 2 [mixed]: the Plist element name or index (names are case sensitive)
							item(s) 3+ [mixed]: additional sub item(s)
		returns [mixed]:	value of the element - null if not found or error
	*)
	try
		tell application "System Events"
			set thePlistElement to property list file ((get the first item of PlistItems) as text) -- start at the root element
			
			repeat with AnItem in rest of PlistItems -- add on the sub items
				set AnItem to the contents of AnItem
				try
					set AnItem to AnItem as integer -- index number?
				end try
				set thePlistElement to (property list item AnItem of thePlistElement)
			end repeat
			
			return value of thePlistElement
		end tell
	on error ErrorMessage number ErrorNumber
		log ErrorMessage
		return null -- error "GetPlistElement handler:  element not found (" & ErrorNumber & ")"
	end try
end GetPlistElement

Thanks for the shoutout man! I’m working on a script right now that will actually self load scripts. No need to script out every script you want to load.

Great. If possible, share your script with us.

Once the kinks are worked out I will gladly post. But for now it is bed time…:lol: