To prevent my script from becoming too “crowded” i’d like to split one script into many.
I’d like to have one script-file that handles the launch process, one script file that that handles every button press, one script-file to check for updates and so on. I tried to accomplish this by adding a new NSObject, the problem is that this new object isn’t connected to any applescript file.
That’s telling you you don’t have a class called NewMessage. The class name is the bit following the word “script” at the beginning of your script file.
Your parent property refers to a class that doesn’t exist. You can’t make an AS class a subclass of another AS class, so that should be NSObject or some other Cocoa class.
f it’s not too complex, you might want to consider deleting most of the things in your interface and redoing them. It sounds like something might have been corrupted.
Rebuilding the interface did work. The only received action that won’t be recognized is sendNewMessage. There must still be something wrong. stay tuned…
when i do this it only recognizes NEWMSGBTN (Just copied that from the other script to test)
script SendMessage
property parent : class "ObjectWithFords"
property test : missing value
property Receiver : missing value
property Subject : missing value
property Content : missing value
on PrepareMessage_(sender)
log "Grabbing textfield value's..."
set theReceiver to Receiver's stringValue() as text
log "Receiver: " & theReceiver
set theSubject to Subject's stringValue() as text
log "Subject: " & theSubject
set theContent to Content's stringValue() as text
log "Content: " & theContent
end PrepareMessage_
on NEWMSGBTN_(sender)
log "New message button triggered"
try
NewMessageWindow's showOver_(MainWindow)
on error
log "NewMessageWindow couldn't showover"
NewMessageWindow's orderFront_(me)
end
end NEWMSGBTN_
end script
And when i do this it only recognizes SendMessage1
script SendMessage
property parent : class "ObjectWithFords"
property test : missing value
property Receiver : missing value
property Subject : missing value
property Content : missing value
on PrepareMessage_(sender)
log "Grabbing textfield value's..."
set theReceiver to Receiver's stringValue() as text
log "Receiver: " & theReceiver
set theSubject to Subject's stringValue() as text
log "Subject: " & theSubject
set theContent to Content's stringValue() as text
log "Content: " & theContent
end PrepareMessage_
on NEWMSGBTN_(sender)
log "New message button triggered"
try
NewMessageWindow's showOver_(MainWindow)
on error
log "NewMessageWindow couldn't showover"
NewMessageWindow's orderFront_(me)
end
end NEWMSGBTN_
on PrepareMessage1_(sender)
log "Grabbing textfield value's..."
set theReceiver to Receiver's stringValue() as text
log "Receiver: " & theReceiver
set theSubject to Subject's stringValue() as text
log "Subject: " & theSubject
set theContent to Content's stringValue() as text
log "Content: " & theContent
end PrepareMessage_
end script
I’m not sure what’s happening. Control-click on the file in Navigator and choose Open with External Editor. This will open it in your script editor; compile it there and save, to make sure it compiles OK.
I’m not sure either. But somehow it is now working perfectly. What i did was make sure i ended the routine correctly and hit tab a few times. It’s working as expected now! Anyway as i’m only at the beginning of this project i’ll probably get a lot more problems (with NSScrollview, mostly). Anyway, thank you both!
I’d like to load handlers from another script. So i tried to use this:
set ScriptLoc to ((current application's NSBundle's mainBundle()'s bundlePath()) as text) & "/Contents/Resources/FirstRun.scpt" as text
set FirstRun to load script ScriptLoc
FirstRun's Boom_()
However it always return me
I tried to set the ScriptLoc as alias and as string, both make it impossible for load script to find FirstRun.scpt. Seeing it says it can’t recognize the function i guess there would be something wrong with the target script. But that doesn’t seem likely to me, sinds the only thing in there atm is the empty Boom_() handler.