Professional Web Applications Themes

FileMaker Developer 6, CodeWarrior 5, Apple Script/AppleEvents - FileMaker

Hi all, This is my first time posting so please forgive me if I do not post properly. We have created an application in C++ using CodeWarrior 5. We have also created a FM Database to manage the data produced by the application. I have quite a few questions. The first is, I want the user to be able to click on a button on the C++ application side, to start/launch/open the fm database. I can do so using Applescripting with a script editor but am unable to do so through C++. I got some code from somewhere (dont remember ...

  1. #1

    Default FileMaker Developer 6, CodeWarrior 5, Apple Script/AppleEvents

    Hi all,

    This is my first time posting so please forgive me if I do not post
    properly.
    We have created an application in C++ using CodeWarrior 5. We have
    also created a FM Database to manage the data produced by the
    application.

    I have quite a few questions. The first is, I want the user to be able
    to click on a button on the C++ application side, to start/launch/open
    the fm database. I can do so using Applescripting with a script
    editor but am unable to do so through C++. I got some code from
    somewhere (dont remember where) and have pasted it below.


    #include <Types.h>
    #include <OSA.h>
    #include <AppleScript.h>

    #include <stdio.h>
    #include <unistd.h>
    #include <stdlib.h>

    #include <string.h>

    /* LowRunAppleScript compiles and runs an AppleScript
    provided as text in the buffer pointed to by text. textLength
    bytes will be compiled from this buffer and run as an AppleScript
    using all of the default environment and execution settings. If
    resultData is not NULL, then the result returned by the execution
    command will be returned as typeChar in this descriptor record
    (or typeNull if there is no result information). If the function
    returns errOSAScriptError, then resultData will be set to a
    descriptive error message describing the error (if one is
    available). */
    static OSStatus LowRunAppleScript(const void* text, long textLength,
    AEDesc *resultData) {
    ComponentInstance theComponent;
    AEDesc scriptTextDesc;
    OSStatus err;
    OSAID scriptID, resultID;
    char *tmp = (char*)text;

    /* 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);
    sleep(3);

    /* 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;
    }


    /* SimpleRunAppleScript compiles and runs the AppleScript in
    the c-style string provided as a parameter. The result returned
    indicates the success of the operation. */
    static OSStatus SimpleRunAppleScript(const char* theScript) {
    return LowRunAppleScript(theScript, strlen(theScript), NULL);
    }


    /* example:
    SimpleRunAppleScript(
    "tell application \"Finder\"\n"
    " activate\n"
    " select folder \"Doents\" of startup disk\n"
    " open selection\n"
    "end tell");

    "tell application \"FileMaker Pro\"\n"
    "tell database \"Patient Data\"\n"
    " activate\n"
    " display dialog \"Patient Data Loaded!\"n"
    " do script \"Load Patient\"\n"
    " display dialog \"Patient Data Loaded!\"n"
    "end tell\n"
    "end tell");
    "tell application \"Macintosh HD:OncoDiagnostic Lab
    9/26/03:OncoDiagnostic iVISION Solution\"\n"
    "launch\n"
    "open file \"Macintosh HD:OncoDiagnostic Lab 9/26/03:OncoDiagnostic
    iVISION Report\"\n"
    " activate\n"
    "end tell");

    "run application \"iVISION Report Solution alias\""
    */

    void main()
    {

    SimpleRunAppleScript("run application \"iVISION Report Solution\"");
    }


    This code runs the script but is extremely slow and does not open up
    the database file requested. It only starts the solution but does not
    display the database itself. What can I do to efficiently open up the
    database through C++ application? Are AppleEvents the answer instead?
    If so, doesnt the FM application need to be open before it can respond
    to any events? Or would I go through Finder?

    Next question is, though related to the first, i want my C++
    application to dump data into the database directly. I do not want to
    have to ask the user to import the data. How do I do this?

    I have some C++ experience and some FM experience. But I am pretty new
    to this interapplication communication business.

    Please advise at the earliest possible time.
    Thanx,
    Uroosa
    Uroosa Guest

  2. #2

    Default Re: FileMaker Developer 6, CodeWarrior 5, Apple Script/AppleEvents

    I can't follow the programming code, but I shouldn't need to do so. You can
    create an AS appllication that opens Filemaker, and simply call that AS app
    from your compiled app. In other words, let AS do all your work for you, and
    don't try to do it in C++. The AS app could also pass a vaue back to a flag
    in the compiled app, telling it to either close, or do something else, or
    learn that the event occurred without error.

    --
    John Weinshel
    Datagrace
    Vashon Island, WA
    (206) 463-1634
    Associate Member, Filemaker Solutions Alliance


    "Uroosa" <com> wrote in message
    news:google.com... 


    John Guest

  3. #3

    Default Re: FileMaker Developer 6, CodeWarrior 5, Apple Script/AppleEvents

    The best way to get another program (like the c++ program you're writing) to
    interact with FileMaker is by setting up FileMaker Web Companion and then
    using FileMaker's CGI spec to pass HTTP requests (commands) to FileMaker.
    In your http request you can request FileMaker to return the results in XML.
    You can then use an XML pr to get the result from FileMaker, which could
    include the result of a query.


    Mariano Guest

  4. #4

    Default Re: FileMaker Developer 6, CodeWarrior 5, Apple Script/AppleEvents

    "Mariano Peterson" <com> wrote in message news:<D_Gsb.189430$Fm2.176567attbi_s04>... 

    That's a long way to go, mariano. John's answer is way better.
    Paul Guest

  5. #5

    Default Re: FileMaker Developer 6, CodeWarrior 5, Apple Script/AppleEvents

    com (Paul Bruneau) wrote in message news:<google.com>... 
    >
    > That's a long way to go, mariano. John's answer is way better.[/ref]

    Thank you so much for all your time. We actually got the code working
    somehow. And now we are able to successfully run applescript in
    through our application.

    Thanx once again,
    Uroosa
    Uroosa Guest

Similar Threads

  1. Question Dot Net 1.1 Web Service Call | Apple Script
    By Anil Singla in forum Brainstorming Area
    Replies: 11
    Last Post: September 13th, 03:43 AM
  2. font in Illustrator CS and Apple Script
    By demon11@adobeforums.com in forum Adobe Illustrator Macintosh
    Replies: 4
    Last Post: May 28th, 09:55 AM
  3. Apple menu script error
    By prw webforumsuser@macromedia.com in forum Macromedia Director Basics
    Replies: 4
    Last Post: July 27th, 04:42 PM
  4. [OFF] FileMaker Pro / Web Developer Job
    By Alternative Systems in forum FileMaker
    Replies: 4
    Last Post: July 11th, 06:32 AM
  5. Run filemaker script on sql server data?
    By Dan in forum FileMaker
    Replies: 1
    Last Post: June 28th, 02:34 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139