I’m getting my feet wet with a small AppleScriptObj project on Mac OS X Lion for an internal application.
Now that I’ve built a working single-file prototype with the latest XCode available for Lion, I’d like to do some code structuring so it’s easier to find find everything back while maintaining and extending the application. I’ve already come to the realization that a simple include or load isn’t really available to make the functions I use that are spread over the different files accessible in the main script so I’m working with the tell class directive instead. I’ve also figured out how to pass along a variable, using the underscore in handler_(thevariable) seems to be a requirement for it to be recognized in the class. But how do I get a variable back into the main code? My pseudocode looks a bit like this :
main.AppleScript:
script main
on dosomestuffwith(this)
set theVariable to this as text
tell class Conversions of current application
set myVariable to transform_(theVariable)
end tell
end dosomestuffwith
end script
conversions.AppleScript:
script Conversions
on transform_(theVariable)
set theResult as “SomethingElse”
return theResult
end transform_
end script
But this doesn’t work. I’ve already tried setting it trough defining a variable in main and using the my … directive as found in the AppleScript developer documentation, but that doesn’t work either. Any ideas on how to achieve what I’m trying to do?
Thanks.