Futurebasic/Language/Reference/usr applescriptgetresult

USR APPLESCRIPTGETRESULT

Revised June, 2003 (Release 8)

Description - This routine returns a handle pointing to the data in memory returned by an AppleScript script executed with USR APPLESCRIPTRUN or USR APPLESCRIPLOADANDRUN. If there is no result or if the routine fails to retrieve the data, the value returned by USR APPLESCRIPTGETRESULT is _nil. You are responsible for the disposing of the handle returned (if any). You must be aware that the routine empties the AppleScript internal buffer. You could possibly use the USR APPLESCRIPTGETRESULT function to retrieve the text source of your entire script right after storing it into the AppleScript buffer using the ROUTE and PRINT statements, however you cannot expect to compile and execute the script afterwards, since the buffer would be empty. In a general manner, you must call the USR APPLESCRIPTGETRESULT function after a script has been executed whether an error occurred or not and dispose of the handle returned if any and if necessary.

Example: The following example will return the list of all the folders located at the root level of your hard drive:

INCLUDE "Subs AppleScript.Incl" DIM AS STR255

DIM AS HANDLE textH

DIM AS RECT r WINDOW 1

CALL SetRect

CALL InsetRect( r, 32, 32 )

NEED LINK!!! EDIT FIELD 1,"",@r ROUTE _toAppleScript

PRINT "the name of every folder of the startup disk"

NEED LINK!!! ROUTE _toScreen err = USR APPLESCRIPTRUN

H = USR APPLESCRIPGETRESULT

LONG IF H

  TESetText([H],FN GetHandleSize(H), TEHANDLE(1))
  DisposeHandle( H )
  CLS

XELSE

  EDIT$( 1 ) = message$

END IF See Also: USR APPLESCRIPLOADANDRUN; USR APPLESCRIPTRUN