include Usage problem

I want to create a fuctions.applescript file and call if from from my other .applescript files but I can’t figure out the syntax.

for interested parties load script

The thing I cant get it to work if I only use project builder. But using script editor first to make a compiled applescript called, lets say test.applescript with the script below makes it work. The only problem I have is that I have to send the app in a folder with the compiled applescripts.

Heres the function in my compiled script file(test.applescipt) made in script editor:

myDisplay(44)
on myDisplay(theNumber)
set mika to (10 * theNumber)
display dialog mika
return mika
end myDisplay

and then in my ASS file I connect them using:

on clicked theObject
set numberLib to (load script file"Hard Disk:Applications:myApp:scripts:test.applescript")
tell theFile
set theMult to myDisplay(“77”)
end tell
end clicked

It’s not the optimal solution because you sometimes have to awake the hard disk to get the file and it makes the app a bit slow. But if I compare that to having all the script code in one file - I thank god this works.

Hope this works for you. If you get problems just tell me and I’s send you a cope of a project!

have fun

you posted to my topic I have found a better way of accomplishing the task in the project builder make a new applescript file called functions in this file you put your functions like


on setProperties()
     --do something
end setProperties

in the applescript file that calls the function put the code


property embeddedScriptObject : "null"

on awake from nib theObject
	if embeddedScriptObject = "null" then
		set dpath to (path to me) as string
		set scriptPath to dpath & "Contents:Resources:Scripts:functions.scpt"
		set embeddedScriptObject to load script file ((scriptPath) as string) 
	end if

end awake from nib

to call the function:


	tell embeddedScriptObject
		setProperties()
	end tell

give it a try it works great for me