The Call AppleScript Function statement provides a programmatic means of invoking AppleScript Functions. The statement always calls a function in the provided AppleScript content. The function can be passed any number of string parameters.
The called function can return nothing, a single value or a list of values. The returned values must be capable of being represented as strings. If they cannot they will be replaced by an empty string. Passed parameters can be decomposed in the AppleScript into lists by separating the components based on a delimiter. The same holds in reverse for returned values.
All text fields may contain any of the escape sequences described in Escape Sequences. The following fields are available:
The action test state will be set to true if there are no errors. The action test state will be false if any errors occurred. Named variable Container Error will contain the errror text. If the Stop action on error option is enabled, the action will be terminated with an error message in the case of an error.
When run stepwise the statement is only executed once.
Assume that named variable script contains:
on RevList(p1, p2, p3) set alist to {p1, p2, p3} set rList to the reverse of alist return rList end RevList
The following statement:
Call AppleScript Function RevList(a\~b\~c) delim(⏎) --> 'res' content='script'
Will set named variable res to:
c⏎b⏎a
The following example describes how to decompose parameters:
Assume that named variable script contains:
on RevList(stringList, delim) set oldDelimiters to AppleScript's text item delimiters set AppleScript's text item delimiters to delim set alist to every text item of stringList set AppleScript's text item delimiters to oldDelimiters set rlist to the reverse of alist return rlist end RevList
The following statement:
Call AppleScript Function RevList(a,b,c,d,e,f\~,) delim(⏎) --> 'res' content='script'
Will set named variable res to:
f⏎e⏎d⏎c⏎b⏎a
Note that two parameters were passed: a,b,c,d,e,f and ,. The called function converts the first parameter to a list.
Note that the script can be written and debugged in Script Editor. You can either copy and paste the text or read it using a Read Text File statement. Note that a .scpt file cannot be read by Yate. You have to export the script as a text file which produces a .applescript file which can be read by Yate.
...and there is no reason to use AppleScript to reverse a list. The List Manipulate statement can reverse lists.