home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connectio…eloper Series 2005 March / Dev.CD Mar 05.iso / What's New / Technical Notes and Q&As / ADC Reference Library / qa / qa2001 / downloads / qa1026.hqx / qa1026 / RunScript.h < prev   
Encoding:
C/C++ Source or Header  |  2001-04-11  |  4.4 KB  |  118 lines

  1. /*
  2.     File: RunScript.h
  3.     
  4.     Description:
  5.         Simple routines for running AppleScripts inside of applications.  Clients
  6.     should either link with CarbonLib or weak link against AppleScriptLib.
  7.  
  8.     Copyright:
  9.         © Copyright 2001 Apple Computer, Inc. All rights reserved.
  10.     
  11.     Disclaimer:
  12.         IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
  13.         ("Apple") in consideration of your agreement to the following terms, and your
  14.         use, installation, modification or redistribution of this Apple software
  15.         constitutes acceptance of these terms.  If you do not agree with these terms,
  16.         please do not use, install, modify or redistribute this Apple software.
  17.  
  18.         In consideration of your agreement to abide by the following terms, and subject
  19.         to these terms, Apple grants you a personal, non-exclusive license, under Apple’s
  20.         copyrights in this original Apple software (the "Apple Software"), to use,
  21.         reproduce, modify and redistribute the Apple Software, with or without
  22.         modifications, in source and/or binary forms; provided that if you redistribute
  23.         the Apple Software in its entirety and without modifications, you must retain
  24.         this notice and the following text and disclaimers in all such redistributions of
  25.         the Apple Software.  Neither the name, trademarks, service marks or logos of
  26.         Apple Computer, Inc. may be used to endorse or promote products derived from the
  27.         Apple Software without specific prior written permission from Apple.  Except as
  28.         expressly stated in this notice, no other rights or licenses, express or implied,
  29.         are granted by Apple herein, including but not limited to any patent rights that
  30.         may be infringed by your derivative works or by other works in which the Apple
  31.         Software may be incorporated.
  32.  
  33.         The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
  34.         WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
  35.         WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  36.         PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
  37.         COMBINATION WITH YOUR PRODUCTS.
  38.  
  39.         IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
  40.         CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  41.         GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  42.         ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
  43.         OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
  44.         (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
  45.         ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  46.  
  47.     Change History (most recent first):
  48.         Wed, Apr 10, 2001 -- created
  49. */
  50.  
  51.  
  52. #ifndef __RUNSCRIPT__
  53. #define __RUNSCRIPT__
  54.  
  55.  
  56.  
  57. #if TARGET_API_MAC_CARBON
  58.  
  59. #ifdef __APPLE_CC__
  60. #include <Carbon/Carbon.h>
  61. #else
  62. #include <Carbon.h>
  63. #endif
  64.  
  65. #else
  66.  
  67. #include <Types.h>
  68. #include <AppleEvents.h>
  69.  
  70. #endif
  71.  
  72.  
  73.  
  74. #ifdef __cplusplus
  75. extern "C" {
  76. #endif
  77.  
  78.  
  79.     /* LowRunAppleScript compiles and runs an AppleScript
  80.     provided as text in the buffer pointed to by text.  textLength
  81.     bytes will be compiled from this buffer and run as an AppleScript
  82.     using all of the default environment and execution settings.  If
  83.     resultData is not NULL, then the result returned by the execution
  84.     command will be returned as typeChar in this descriptor record
  85.     (or typeNull if there is no result information).  If the function
  86.     returns errOSAScriptError, then resultData will be set to a
  87.     descriptive error message describing the error (if one is
  88.     available).  */
  89. OSStatus LowRunAppleScript(const void* text, long textLength, AEDesc *resultData);
  90.  
  91.  
  92.     /* SimpleRunAppleScript compiles and runs the AppleScript in the c-style
  93.     string provided as a parameter.  The result returned indicates the success
  94.     of the operation. */
  95. OSStatus SimpleRunAppleScript(const char* theScript);
  96.  
  97.  
  98.     /* AppleScriptAvailable returns true if AppleScript is available
  99.     and the routines defined herein can be called. */
  100. Boolean AppleScriptAvailable(void);
  101.  
  102.  
  103. /* example:
  104.    SimpleRunAppleScript(
  105.        "tell application \"Finder\"\n"
  106.        "  activate\n"
  107.        "  select folder \"Documents\" of startup disk\n"
  108.        "  open selection\n"
  109.        "end tell");
  110.    */
  111.  
  112.  
  113. #ifdef __cplusplus
  114. }
  115. #endif
  116.  
  117. #endif
  118.