Did you know you can have multiple scripts?

Hey MacScripter, and AppleScriptObjC coders alike!
I’m not sure if you all knew this, but you know how there’s the “AppDelegate” script? If you add extra scripts after that, and create the object in your interface, you can use that script.(See the example below)

script AppDelegate
	property parent : class "NSObject"
	on applicationWillFinishLaunching_(aNotification)
	end applicationWillFinishLaunching_
	on applicationShouldTerminate_(sender)
		return current application's NSTerminateNow
	end applicationShouldTerminate_

end script

script ScriptWithVariableNeeded
    property NeededVariable : false
end script

script MeatAndTaters
if NeededVariable = true then return
end script

Can anyone help me find a way to import NeededVariable into MeatAndTaters?

You can, but it’s usually more convenient to store them as separate files.

Make instances of them both (blue cubes), add a property to MeatAndTaters set to missing value and connect it to the NeededVariable instance, then use the property to ask the NeededVariable instance for the value with NeededVariable().

I’m sorry, I mean use NeededVariable from ScriptWithVariableNeeded in MeatAndTaters.

Where I said NeededVariable instance, it should have been ScriptWithVariableNeeded instance. Your code would look like:

script ScriptWithVariableNeeded
property NeededVariable : false
end script

script MeatAndTaters
property swvnInstance: missing value -- connected to instance of ScriptWithVariableNeeded in UI

on doSomething()
if swvnInstance's NeededVariable() as boolean = true then return
end doSomething

end script

I keep getting the following: The variable NeededVariable is not defined.
for some reason.

It sounds like you haven’t mad the two instances.

to be honest, I don’t know how to fix it, so I’ll just post my source code. screw secrets! lol

It’s the beginning behind my converters. (why yes, I am trying to be techspansion) Any help would be appreciated.