[futurebasic] Re: [FB] Launching applications

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2002 : Group Archive : Group : All Groups

From: Pete <furbies@...>
Date: Fri, 04 Jan 2002 23:24:30 +1100
David Cottrell on 4/1/02 12:52 PM  scrawled:

> A quick search of the archive reveals a  number of different ways to
> sublaunch and external application from within an FB application, but
> all the examples I have found require that you know the location of the
> external application (eg FB's RUN command)
> 
> However, a number of applications I have seen let you launch an
> application without there being any way that they could know where I
> have hidden it on my HD.
> 
> Does anyone know how they do it?
> 
> Thanks
> 
> David

try this:

/* These constants are used to send the open file appleevent */
begin enum
_kAEQueueReply         =  2/* AESend */
_kAECanInteract        = 32/* -- " -- */

_kAutoGenerateReturnID = -1
_kAnyTransactionID     = 0
_kAENormalPriority     = 0
_kAEDefaultTimeout     = -1
end enum

local mode
local fn openTextFileInOriginalEditor(fName as str63, vRefNum as int)

DIM AS OSErr    err
DIM AS OSType @ creator
DIM AS FSSpec   fspec
DIM AS AEDesc   addrDesc,theAE,fList

LONG IF FN FSMakeFSSpec(vRefNum, _nil, fName, fSpec) = _noErr
creator = _"MACS"/* creator of Finder (application signature) */
err = FN AECreateDesc(_"sign", @creator, SizeOf(OSType), addrDesc)/*
AEDescriptor of Finder address */
IF err THEN EXIT "Dispose"
err = FN AECreateAppleEvent(_"aevt", _"odoc", addrDesc,¬
 _kAutoGenerateReturnID, _kAnyTransactionID, theAE)/* builds AppleEvent
(theAE) */
IF err THEN EXIT "Dispose"
err = FN AEcreateList(_nil, 0, _false, fList)/* create empty list Desc */
IF err THEN EXIT "Dispose"
err = FN AEPutPtr(fList,1, _"fss ", fSpec, SizeOf(FSSpec))/* single FSSpec
to list */
IF err THEN EXIT "Dispose"
err = FN AEPutKeyDesc(theAE, _"----", fList)/* list of FSSpecs to theAE */
IF err THEN EXIT "Dispose"
err = FN AESend(theAE, addrDesc, _kAEQueueReply_kAECanInteract,¬
 _kAENormalPriority, _kAEDefaultTimeout, _nil, _nil)/* send theAE to Finder
*/
"Dispose"
err = FN AEDisposeDesc(addrDesc)
err = FN AEDisposeDesc(theAE)/* deallocates AEDescriptors */
err = FN AEDisposeDesc(fList)

END IF

end fn


enjoy

-- 
Pete...                     (the other one)