How to Use AppleScript Scripts to Return Values to FoxProID: Q108622 2.50b 3.00b MACINTOSH
The information in this article applies to:
SUMMARYThe AppleScript language supports a RETURN statement that allows the author of a script to send a result back to the calling procedure. The calling procedure can be a FoxPro program, command, or procedure. Examples are provided below. NOTE: AppleScript is manufactured by a vendor independent of Microsoft; we make no warranty, implied or otherwise, regarding this product's performance or reliability.
MORE INFORMATIONA script, which is a series of one or more commands supported by the AppleScript language, is analogous to a procedure written in Microsoft FoxPro or some other high-level language. Like procedures, a script can communicate with a calling program by returning a value to it. To run a script from within Microsoft FoxPro for Macintosh, use the following command syntax:
If the script terminates with a RETURN statement, that value is returned to
FoxPro and stored in the optional parameter to the RUNSCRIPT command.
The following example is an elementary AppleScript script that simply returns a Boolean, or logical, value:
The following example illustrates how FoxPro for Macintosh can store a
value to a variable named retVal from an AppleScript script named MyScript:
Although AppleScript supports a variety of extended types, or classes, such
as lists, records, and aliases, FoxPro transforms them into simple
character expressions when storing them.
Since only a single value can be returned from an AppleScript script and FoxPro for Macintosh does not support the passing of parameters to an AppleScript script, a character expression delimited with commas or some other value is recommended. Since AppleScript supports the list as a standard class, it makes sense to take advantage of it to build a list of return values. For example, the following AppleScript returns multiple values to the calling program by building a list object:
If you save the script, name it MyScript2, and invoke it issuing the
following command in the FoxPro Command window:
The list is returned to FoxPro as a character string delimited with commas.
In this case, the character expression "First, Last" is returned, and the
individual values can be returned using FoxPro's arsenal of string-
manipulation functions such as SUBSTR() and AT(). The following FoxPro code
snippet extracts the elements from retVal and stores the individual values
to new variables:
For more information about AppleScript, including a detailed explanation of
the language and its supported types, see the "AppleScript Developer's Kit"
from Apple Computer.
Additional reference words: vFoxMac 3.00b FoxMac 2.50b KBCategory: kbtool kbprg KBSubcategory:
|
Last Reviewed: May 12, 1998 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |