Given: script with multiple functions in it (see below)
Wanted: call a function by name from command line, e.g. osascript lib.scpt fn1
Problem: Executing the above command gives “lib.scpt: execution error: «script» doesn’t understand the argv message. (-1708)”
How can I call a function by name?
on run argv
argv() // <-- here's the problem
end run
on fn0()
return "hello from fn0"
end fn0
on fn1()
return "hello from fn1"
end fn1
I think I’ve found what you’re looking for on MacScripter: