Hi William ,
Thanks for your correction.

Im calling my script form within native application (C++ Carbon) and
passing attachment file as parameter. Actual code  is appended to the end.
I test my script using Script Editor and it works OK , when I call it form
my application code  attached file disappears.
I'm not  quite sure I understand Automator thing - could you please
elaborate on it? I haven't used it before.

Many thanks
David



OSStatus LowRunAppleScript(const void* text, long textLength,
                                  AEDesc *resultData) {
    ComponentInstance theComponent;
    AEDesc scriptTextDesc;
    OSStatus err;
    OSAID scriptID, resultID;

    /* set up locals to a known state */
    theComponent = NULL;
    AECreateDesc(typeNull, NULL, 0, &scriptTextDesc);
    scriptID = kOSANullScript;
    resultID = kOSANullScript;

    /* open the scripting component */
    theComponent = OpenDefaultComponent(kOSAComponentType,
                                        typeAppleScript);
    if (theComponent == NULL) { err = paramErr; goto bail; }

    /* put the script text into an aedesc */
    err = AECreateDesc(typeChar, text, textLength, &scriptTextDesc);
    if (err != noErr) goto bail;

    /* compile the script */
    err = OSACompile(theComponent, &scriptTextDesc,
                     kOSAModeNull, &scriptID);
    if (err != noErr) goto bail;

    /* run the script */
    err = OSAExecute(theComponent, scriptID, kOSANullScript,
                     kOSAModeNull, &resultID);

    /* collect the results - if any */
    if (resultData != NULL) {
        AECreateDesc(typeNull, NULL, 0, resultData);
        if (err == errOSAScriptError) {
            OSAScriptError(theComponent, kOSAErrorMessage,
                           typeChar, resultData);
        } else if (err == noErr && resultID != kOSANullScript) {
            OSADisplay(theComponent, resultID, typeChar,
                       kOSAModeNull, resultData);
        }
    }

    bail:
    AEDisposeDesc(&scriptTextDesc);
    if (scriptID != kOSANullScript) OSADispose(theComponent,
scriptID);
    if (resultID != kOSANullScript) OSADispose(theComponent,
resultID);
    if (theComponent != NULL) CloseComponent(theComponent);
    return err;
}


On Fri, Jul 2, 2010 at 6:38 AM, Smith William <[email protected]> wrote:

> On 6/30/10 4:49 AM, "David Shulman" <[email protected]> wrote:
>
> >Hi I have simple applescript
> >
> >activate application "Microsoft Entourage"
> >set filepath to "Macintosh HD:Users:test:del2pdf"
> >tell application "Microsoft Entourage"
> >set newMessage to make new draft window
> >make new attachment at newMessage with properties {file:filepath}
> >end tell
>
> I think Diane's suggestion to use Automator is best for something like
> this. Just thought I'd point out some things in your script. The shorter a
> script can be, the better and the easier to troubleshoot.
>
> First, you're calling Entourage twice, once to "activate" it or bring it
> forward and again to create a new message. You really only need to do this
> with one "tell" statement.
>
>  tell application "Microsoft Entourage"
>  activate
>   set newMessage to make new draft window
>  make new attachment at newMessage with properties {file:filepath}
>  end tell
>
> The "set" statement can be either within or outside of the "tell"
> statement.
>
> I'm not quite sure how you're calling the the script. Are you using VBA or
> a shell script to open the Script Editor each time, enter the script and
> run it? If you don't want to use Automator then you may want to save the
> AppleScript as an application itself and call that. If you're creating a
> shell script then you may want to consider using the "osascript" command
> for running your AppleScript syntax.
>
> --
>
> William Smith
>
>
> --
> YouTalk mailing list
> List information: http://nine.pairlist.net/support_options/list.html
> List moderator: [email protected], [email protected]
> To unsubscribe: mailto:[email protected]
> ?subject=unsubscribe
>
--
YouTalk mailing list
List information: http://nine.pairlist.net/support_options/list.html
List moderator: [email protected], [email protected]
To unsubscribe: mailto:[email protected]?subject=unsubscribe

Reply via email to