Universal code line to call a library ...

In a thread wrote in 2004, a one line statement could execute «any» handler with «all it’s parameters» if required. This was the resulting thread message:

--An example of the universal code line to call a library
Call("DeltaTimeLib", {2, 6.5})

---The handler that you paste in your script somewhere .....

on Call(libraryName, parameterList)
   copy (load script file ((path to scripting additions as string) & libraryName)) to loadResult
   run script loadResult with parameters parameterList
end Call

---The Run handler that will be called by the 1 line universal statement (compiled script located in your scripting additions folder):
on run {deltaDays, deltaHours}
   set theDate to current date
   set theDate to theDate + (deltaDays * days)
   set theDate to theDate + (deltaHours * hours)
   return theDate
end run

Loading this script in the Script Editor now returns garbage statements and commands. How can I adapt it to today’s AppleScript ?

Thanks in advance.

Robert Lespérance

Hi rlesperance,

When modifying the script slighlty, I have no problems running it on my Mac. But of course you need to save the «on run» handler part into a second script named «DeltaTimeLib.scpt» and place it into /System/Library/ScriptingAdditions/

Then you can run:


--An example of the universal code line to call a library
Call("DeltaTimeLib.scpt", {2, 6.5})

---The handler that you paste in your script somewhere .....
on Call(libraryName, parameterList)
	copy (load script file ((path to scripting additions as string) & libraryName)) to loadResult
	run script loadResult with parameters parameterList
end Call