“… and I heard a voice crying out from heaven saying, 'Behold the script object and blessed be its implementation.”
Ok, so I’m starting to grasp the Script Object (and Script Object within a Handler) syntax. There are some definite correlations going on in my brain about .h and .m files in Cocoa. While it may not be as extensive as Cocoa/ObjC, I really think that tis is a very overlooked and misunderstood area of scripting. There’s some real power in this stuff that I believe most people are missing. Can I prove it? Not yet! Incredibly, some of this is really starting to make sense! Thanks to Adam, Nigel, HHas, etc. who gave some extra clues to what’s happening here.
Anyways… I’m thinking about implementation… I can intuit times when SObj’s would be appropriate and others when SObj’s within Handlers may be more flexible. So here’s my first attempt at a script object written raw (no reference - just (hopefully) understanding the syntax and structures)…
property folderPath : (path to desktop)
property intLabelIndex : 1
property subFolders : {"IMG", "URLS", "PDFs", "Downloads", "Music"}
global myNewFolder
script myFolder
on makeFolder(folderName, folderDestination, Foldercolor)
tell application "Finder"
set myNewFolder to make new folder at folderDestination with properties {name:folderName}
set label index of myNewFolder to Foldercolor
end tell
end makeFolder
return myNewFolder
end script
tell myFolder to makeFolder(((short date string of (current date)) & " Unfiled"), folderPath, intLabelIndex)
set {FilingFolder, intLabelIndex} to {myNewFolder, 3}
repeat with thisFolder in subFolders
tell myFolder to makeFolder(thisFolder, FilingFolder, intLabelIndex)
end repeat
tell application "Finder"
open FilingFolder
set current view of window 1 to column view
end tell
Obviously, it’s a simple folder maker. It may seem like overkill but lessons are being learned here. I do thinnk there’s plenty of opportunity to make it smarter / more concise but it’s early in the ballgame. We’ll see what happens. Thanks again.
Jim Neumann
BLUEFROG
P.S. I’m not real happy with the global for myNewFolder but I’m working on it!