Access App label from an external applescript file

I have an App that accepts user input and passes the input for processing to an applescript file that isn’t part of the Xcode project. The app has a label that displays error Messages. I want to know how I can access this label from the file?

This is the code that I have so far:

App Code:

script FormAppDelegate
property parent : class "NSObject"
property aFname : missing value
property aLname : missing value
property aWindow : missing value
property aErrorMsg : missing value

on button_commitClick_(sender)
set Firstname to aFname's stringValue() as string
set Lastname to aLname's stringValue() as string

set myLib to ((path to applications folder) as string) & "Common Scripts:Library:"
set myProclib to load script (myLib & "ProcessLib.scpt") as alias
myProclib's checkInput(Firstname, Lastname)
end button_commitClick_

end script

This is the checkInput function inside the ProcessLib.scpt file:

on checkInput(Firstname, Lastname)
if Firstname is equal to "" or Lastname is equal to "" then
 aErrorMsg's setStringValue_("Required information missing.")
end if
end checkInput

Obviously this gives rise to an error “The variable aErrorMsg is not defined. (error -2753)”. Can I access the label aErrorMsg from this file?

Try setting aErrorMsg as a third argument in the handler.

But if you’re writing handlers that are ASObjC-exclusive like this, life will probably much easier is you put the code in separate ASObjC classes, rather than loading them as script objects.

Thanks Shane, passing aErrorMsg as a third argument in the handler worked. I don’t know how I overlooked it.