[futurebasic] RE: [FB] front process switch

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 2000 : Group Archive : Group : All Groups

From: "Edwards, Waverly" <wedwards@...>
Date: Wed, 6 Dec 2000 14:22:44 -0500
Just in case someone is interested.  After much research and trying I
decided to go a different
route because it appeared that I couldnt do exactly what I wanted

Here is what I ended up with.  Using this in console mode I was able to
locate the
type and creator I wanted (it was a unique application).  After I found the
application
I called the toolbox LAUNCHAPPLICATION using the _launchDontSwitch flag so
the app is never
a front process.  It worked perfectly.

One of the coolest things about this is that I didnt know about the toolbox
CATSEARCH (PBCATSEARCHSYNC)
until I started looking for ways to find the application using desktop
database.  You cant always find
the app you want using the desktop database because it depends on the
database being correct. 
If the desktop database isnt up to date, you may never find the app.
CATSEARCH is fast.  It searched
my entire drive in 67 ticks (just a few ticks more than a second).  No
matter where I put the file to
test for search speed, it never took more than 69 ticks.

You can use other criteria than I used such as modified date, file names,
finder info, etc.  I chose
creator and type.

I made a few changes and fixed some errors but it works perfectly well.  I
now know that you dont have
to index through the entire volume yourself to find what you want. 

See IM File manager for more details.


W.


//-------------------------
// Modified version of Ross W. Lambert's "PBCatSearch Demo"
// Copyright © 1995 Ariel Publishing, Inc.  All Right Reserved
// Minor mods and bug fixes 12/6/00 Waverly
//-------------------------

_maxFiles      = 700
_csParamSz     = 200
_cInfo         = 200
_buffSz        = 16384
_plusOne       = 1

begin record MyFSSpec
dim vRefNum%/// as short
dim parID&/// as long
dim name$ as str63/// as str63
end record

DIM gFileSpec(_maxFiles_plusOne) as MyFSSpec
DIM gCatSrchPB.csParamSz// see IM File Manager
DIM gSpec1.cInfo// see IM File Manager
DIM gSpec2.cInfo// see IM File Manager
DIM gBuffer.buffSz// see IM File Manager

END GLOBALS


LOCAL MODE
CLEAR LOCAL
LOCAL FN getDir$(dirID&)
dim osErr%
DIM pBlk.220
DIM 31 fldr$

pBlk.ioNamePtr&        = @fldr$
pBlk.ioDRDirID&        = dirID&
pBlk.ioFDirIndex%      = -1
osErr% = FN GETCATINFO(@pBlk)
END FN = fldr$

clear local
local fn startSearch
DIM pBlk.128

TEXT _Monaco,9
dim fName$,dirID&,osErr%,i
dim@ wdRef%


osErr% = FN GetVol(@pBlk)// get the startup volume ref num and store in
paramater block
gCatSrchPB.ioVRefNum%       = pBlk.ioVRefNum%// start at this volume
gCatSrchPB.ioMatchPtr&      = @gFileSpec(1) // put names here
gCatSrchPB.ioReqMatchCount& = _maxFiles // don't give more than this many
gCatSrchPB.ioSearchBits&    = _fsSBFlFndrInfo%
gCatSrchPB.ioSearchInfo1&   = @gSpec1
gCatSrchPB.ioSearchInfo2&   = @gSpec2
gSpec1.ioBuffer.fdType&     = _"APPL"// The type you are looking for
gSpec1.ioBuffer.fdCreator&  = _"CCPr"// The creator you are looking for
gSpec2.ioBuffer.fdType&     = -1 // all bits significant
gSpec2.ioBuffer.fdCreator&  = -1 // all bits significant
gCatSrchPB.ioOptBuffer&     = @gBuffer
gCatSrchPB.ioOptBufSize&    = _buffSz

PRINT "SearchingÉ"
DIM crntTime&, count&

crntTime& = FN TICKCOUNT
'DO
'osErr% = FN catSearch(@gCSPB)
'inc(count&)
'UNTIL osErr% <> _noErr
osErr% = FN catSearch(@gCatSrchPB)

long if osErr% = -39 // in this case a -39 (EOF) is good. We've finished
searching
long if gCatSrchPB.ioActMatchCount& > 0
print "Volumes searched = ";count&
PRINT "Matches found: ";gCatSrchPB.ioActMatchCount&
PRINT "Found in ";FN TICKCOUNT - crntTime&;" Ticks"
print 
FOR i = 1 TO gCatSrchPB.ioActMatchCount&
PRINT i,gFileSpec.name$(i),FN getDir$(gFileSpec.parID&(i))
NEXT
xelse
print "No matches found"
end if
xelse
print "Error =";osErr%
end if

end fn

fn startSearch

-----Original Message-----
From: Edwards, Waverly [mailto:wedwards@...]
Sent: Tuesday, December 05, 2000 2:22 PM
To: 'fblist'
Subject: [FB] front process switch



I'm trying to launch a server application using appleevents using the
APPLEEVENTS.FLTR.    The purpose is to call a dummy file that will force the
finder to launch the server application.  Since I'll have no idea where on
the users volume the file is located I [thought] this was a good idea.  

I have two problems: 

1.  After my app finishes running the server app moves to the front even
though I've set the front process 
     to the client app
2.  The server app looks like its the foreground app.  The name of the
server app when launched continues to
     appear in the menu bar until my app (the client) is finished.

I've tried waiting for events using WAITNEXTEVENT or EVENTAVAIL but that
doesnt seem to help even though IM seems to say that what I need to do.

If I knew where the server app was located I could just call
LAUNCHAPPLICATION using the _launchDontSwitch control flag but the app could
be anywhere on the machine.

Any suggestions?

>>>>>>>>>>

the rest chopped off