[futurebasic] Re: search a folder for files of a certain type...

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

From: Craig Hoyt <aztech4mac@...>
Date: Thu, 13 Jul 2000 15:42:24 -0700
Thanks bowerbird, took your routines and pared them down a little and 
it works great!

<You Wrote>-----------------------------------------------------------------
>'  these routines will search a folder for files of a certain type...
>
>COMPILE 0,_caseinsensitive
>gtypefound=0
>END GLOBALS
>GOTO "main"
>
>CLEAR LOCAL FN getfiledata (filename$,vrn%)
>   DEFSTR LONG                                     'To get type and creator as
>text
>   DIM pbPtr.128, 63 filename$
>   DIM vrn%
>   DIM iopb.128, 63 frName$
>   pbPtr.ioCompletion&=_nil
>   pbPtr.ioNamePtr&=@filename$                     'File Name from FILES$
>   pbPtr.ioVRefNum%=vrn%        'Volume Reference Number from FILES$
>   pbPtr.ioFDirIndex%=0                            'Use vRefNum alone
>   OSErr=FN GETFILEINFO(@pbPtr)
>   LONG IF OSErr         'could be better
>     BEEP
>     EXIT FN
>   XELSE
>     CALL IUDATESTRING(pbPtr.ioFlCrDat&,_longDate,D$)
>     CALL IUTIMESTRING(pbPtr.ioFlCrDat&,_false,T$)
>     CALL IUDATESTRING(pbPtr.ioFlMdDat&,_longDate,D2$)
>     CALL IUTIMESTRING(pbPtr.ioFlMdDat&,_false,T2$)
>     iopb.ioCompletion&=_nil
>     iopb.ioNamePtr&=@frName$   'Folder Name, filled in by GETCATINFO
>     iopb.ioVRefNum%=vrn%       'Volume Reference Number from FILES$
>     iopb.ioFDirIndex%=-1                          'Return info about the
>folder
>     iopb.ioDrDirID&=0                             'Use vRefNum alone
>     OSErr=FN GETCATINFO(@iopb)
>     LONG IF OSErr                                 'could be better
>       BEEP
>       BEEP
>       EXIT FN
>     XELSE
>       ViewNum%=iopb.ioDrUsrWds.frView%
>       ViewBy%=PEEK(@ViewNum%)                     'Folder View in Finder (by
>Number)
>       NumFiles%=iopb.ioDrNmFls%
>       CALL IUDATESTRING(iopb.ioFlCrDat&,_longDate,DF$)
>       CALL IUTIMESTRING(iopb.ioFlCrDat&,_false,TF$)
>       CALL IUDATESTRING(iopb.ioFlMdDat&,_longDate,DF2$)
>       CALL IUTIMESTRING(iopb.ioFlMdDat&,_false,TF2$)
>       type&=pbPtr.ioFlUsrWds.fdType&              'file type
>       type$=MKI$(type&)                           'convert it to text
>       creator&=pbPtr.ioFlUsrWds.fdCreator&        'file creator
>       creator$=MKI$(creator&)                     'convert it to text
>
>       LONG IF (type$="TEXT")
>         gtypefound=gtypefound+1
>         buttontop=gtypefound*(WINDOW(_height)/12)
>         gtypefoundplus7000=gtypefound+7000
>         ll=WINDOW(_width)/4
>         tt=buttontop
>         rr=WINDOW(_width)/4+WINDOW(_width)/2
>         bb=buttontop+WINDOW(_height)/12
>         BUTTON gtypefoundplus70001,filename$,(ll,tt-10)-(rr,bb-10),_push
>         WINDOW FILL
>       END IF
>
>     END IF
>   END IF
>   WINDOW FILL
>END FN
>
>CLEAR LOCAL FN makefilelist(vrn%,dirid&)
>   DIM pblock.128
>   pblock.ionameptr&=@filename$
>   pblock.iovrefnum%=vrn%
>   fileindex%=1
>   DO
>     pblock.iodirid&=dirid&
>     pblock.iofdirindex%=fileindex%
>     oserr%=FN GETCATINFO(@pblock)
>     kfolderbit=3
>     LONG IF FN BITTST (pblock.ioflattrib%,kfolderbit)
>       LONG IF oserr%=_false
>         REM FN makefilelist (vrn%,pblock.iodirid&)    ' recurse if itsa folder
>       END IF
>     XELSE
>       LONG IF oserr%=_false
>         LONG IF gtypefound<9 : REM ...or however many you want...
>           FN getfiledata (filename$,vrn%)
>         END IF
>       END IF
>     END IF
>     INC (fileindex%)
>   UNTIL oserr%
>   seventhousandplusmore=7000+gtypefound+1
>   buttontop=gtypefound*(WINDOW(_height)/12)+(WINDOW(_height)/12)
>   ll=WINDOW(_width)/4
>   tt=buttontop
>   rr=WINDOW(_width)/4+WINDOW(_width)/2
>   bb=buttontop+WINDOW(_height)/12
>   BUTTON seventhousandplusmore,1,"more...",(ll,tt+10)-(rr,bb+10),_push
>END FN
>
>CLEAR LOCAL FN getdirid (vrn%)
>   DIM pblock.128
>   pblock.ionameptr&=0
>   pblock.iovrefnum%=vrn%
>   pblock.iodirid&=0
>   oserr%=FN GETCATINFO (@pblock)
>END FN=pblock.iodirid&
>
>"main"
>WINDOW 1,"",(0,0)-(500,320),_dialogshadow
>vrn%=0
>dirid&=FN getdirid (vrn%)
>FN makefilelist (vrn%,dirid&)
>DO
>   HANDLEEVENTS
>UNTIL 0

======================================================================
AzTech Professional On-Site Service

* Craig Hoyt
* Phone: 818-888-8709   Fax: 818-888-8725
* E-mail: craig@...
* Web: http://www.aztech4mac.com

Macintosh Technology Solutions Since 1984
=======================================================================