[futurebasic] Re: [FB] AppleEvent OpenDoc (folder)

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 2003 : Group Archive : Group : All Groups

From: Alain Pastor <apastor@...>
Date: Fri, 16 May 2003 21:24:20 +0200

Robert Covington wrote:
> 
> In Slide Freebie, I have always used FinderInfo to open folders dragged 
> onto the app icon rather than AppleEvents.
> 
> However a user has pointed out that AEOpenDoc doesn't work (Ah, nothing 
> there, was harder to do back then. :) )
> 
> So I need to implement this so they can run the thing with an 
> Applescript telling it which folder to open, getting away from FinderInfo.
> 
> Example script :
> 
> Tell Application "Slide Freebie v2.3"
>  Activate
>  Open "Test Slides"
> End Tell
> 
> 
> Test Slides is a folder. But I can't seem to get that info from the 
> Apple event for sending on to my search FN.
> 
> Here's my AEReadDocList, which is called in AEOpenDocument. But I can't 
> see that I get to the interior portion ever, via AppleScript.
> 
> Any clarifications or existing examples welcomed.


I don't know if that will answer your question but here is what I do 
in Code Styler (actually I don't know if that works, I don't remember 
having tested). First you must do this:

KILL APPLEEVENT _kRequiredEventClass, _kAEOpenDocuments
ON APPLEEVENT ( _kRequiredEventClass, _kAEOpenDocuments ) FN AEReadFile

this installs your own vector.

Then I have this that I have slightly edited to make it clearer. I 
check the incoming files with their creator code an file type, your 
test may be different.

CLEAR LOCAL FN AEReadFile
'~'9
DIM AS INT     i
DIM AS AEDesc  AEDesc
DIM AS FSSpec  fSpec
DIM AS LONG @  count, actualSize, keyWord, rtnType
DIM AS FInfo   info
DIM AS BOOLEAN OKToGo

LONG IF FN AEGetParamDesc( gFBAEEvent, _keyDirectObject, _typeAEList, 
AEDesc ) = _noErr
LONG IF FN AECountItems( AEDesc, count ) = _noErr' how many files were 
dropped?
FOR i = 1 TO count
OKToGo = _false
LONG IF FN AEGetNthPtr( AEDesc, i, _typeFSS, keyWord, rtnType, @fSpec, 
SIZEOF(FSSpec), actualSize ) = _noErr
LONG IF FN FSpGetFInfo( fSpec, info ) = _noErr
OKToGo = ( info.fdType == _"TYPE" AND info.fdCreator == _"CREA")
END IF
IF OKToGo THEN FN ReadFile( fSpec )
END IF
NEXT
END IF
i = FN AEDisposeDesc( AEDesc )
END IF

END FN

Alain