[futurebasic] Re: [FB] Sending an AppleEvent to a program that is not running.

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 2001 : Group Archive : Group : All Groups

From: George Beckman <gbeckman@...>
Date: Sat, 15 Sep 2001 23:58:25 -0700
on 9/15/01 9:32 AM, Ian Mann at i.mann@... wrote:

> I need to send a list of file names to another program.
> 
> The other program should start itself up and process the files.
> 
> I think this is easy but I can't remember where I've seen the how to.
> 
> Any Ideas ???


Ian,

I do it this way.  (Actually, I have app #1 write a file that App #2 will
process.)   I work in PG so you may have to find you own routines.


First, each program needs to have its own creator signature.

(you may not need this step)
I write the file with the second program's creator


Then is is just a matter of sending an AppleEvent that opens the file, just
as if you double clicked it... the Finder will call app #2 and all will be
well.
gHandyVar=FN AEOpenFile("The File",gSaveVol)

If the app is open then...
This will send the gTheFile$ to the App "My Second App"
FN gAESendMsg(gTheFile$,"My Second App")

In a PG app, this looks for the event.  I send an "I'M Awake to make sure we
actually have a dialog. Otherwise you may be sending stuff and there is no
one on the other end of the line.  Here my users are viewing the files and
manipulating them or tossing them.  You can toss the other window build
stuff...


  CASE _otherNullEvent
    LONG IF gWakingUp%=1
      FN AESendMsg("I'm Awake","App One")
      gWakingUp=0
    END IF
    
    LONG IF LEN(gAEinfo$)'STAZ kindly fills this if there is an AppleEvent
      gImportFileName$=gAEinfo$
      gAEinfo$=""
      LONG IF LEN(gSaveName$)=0
        FN pGbuild(_infoCheckWnd)
      XELSE
        CALL PARAMTEXT("Hey, App 2 just sent another file.  If you don't
want it, cancel the next dialog.","","","")
        FN pGshowErr(0)
        FN pGbuild(_ApplyThisToWnd)
        gMyAction=0
        FN PutApply
        
      END IF
    END IF


Hope this helps.
-- 
Best Wishes,

George
mailto: gbeckman@...
http://www.pggp.com