Guidance
指路人
g.yi.org
software / rapidq / Examples / File & Directory / rdir.bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
' Recursive search files in subdirectories
' using  DIR$ SYSTEM Function (Windows)
' Andrew Shelkovenko diakin66@elm.ru
' 12/2002

     $INCLUDE "RAPIDQ.INC"
     DECLARE FUNCTION GetFocus LIB "user32" ALIAS "GetFocus"() AS LONG
     DECLARE FUNCTION Setfocus LIB "user32" ALIAS "SetFocus"(hwnd AS LONG) AS LONG

     DECLARE SUB GoDirs
     DECLARE SUB dirs
     DECLARE SUB StopS
     DECLARE SUB VisDir(Button%, X%, Y%, Shift%)
     DECLARE SUB ChangeDirectory
     DEFINT   StopS1

     DIM Timer1 AS QTIMER
     DIM dateR AS STRING
     dateR=MID$(DATE$, 4,3)+ MID$(DATE$, 1,3)+MID$(DATE$, 7,4)
     DECLARE SUB TimerOver
     Timer1.Interval = 400
     Timer1.Enabled = 1 'True
     Timer1.OnTimer = TimerOver


     CREATE Form AS QFORM
      CAPTION = "Form1"
      Width = 640
      Height = 450
      Center
''    OnClick=VisDir
      OnMouseDown=VisDir
      OnMouseMove=VisDir
      OnHint=VisDir
      CREATE Button1 AS QBUTTON
       CAPTION = "GoDirs!"
       Left = 455
       Top = 8
       OnClick=GoDirs
      END CREATE
      CREATE Button2 AS QBUTTON
       CAPTION = "Stop"
       Left = 540
       Top = 8
       OnClick=StopS
      END CREATE
      CREATE ListView AS QLISTVIEW
       Top = 41
       Width = 601
       Height = 353
       CheckBoxes=true
       ViewStyle = vsReport
       AddColumns "FileName","Size","Date","Time"
       Column(0).Width = 400
       Column(1).Width = 40
       Column(2).Width = 70
       Column(3).Width = 70
    'OnDblClick = ItemDblClick
      END CREATE
      CREATE Label1 AS QLABEL
       top =400
       Left = 10
       CAPTION = "All hits "

      END CREATE
      CREATE Edit1 AS QEDIT
       Text = "c:\My Documents\"
       Left = 14
       Top = 8
       Width = 300
       TabOrder = 10
       OnChange=VisDir
       Hint="§ à § !"
       ShowHint=true
      END CREATE
      CREATE MaskBoxYes AS QCOMBOBOX '==== ¬ áª 
       Text = "*.*htm*"
       Left = 320
       Top = 8
       TabOrder = 2
       Width =100
       AddItems "*.txt", "*.*htm*", "*.", "*.*", "*.ctl"
      END CREATE
      CREATE DirTree AS QDIRTREE
       Align=center
       top=28
       Left = 14
       InitialDir = "c:\temp"
       Width =300
       Height =Form.ClientHeight /2
''            OnChange =ChangeDirectory1
       TabOrder=1
       ShowHint=false
       font.COLOR=clDred
         ''   HideSelection=True
       visible=false
       OnChange = ChangeDirectory
      END CREATE

     END CREATE

'Insert your initialization code here

     Setfocus(Edit1.handle):       Edit1Hnd = GetFocus()
     Setfocus(MaskBoxYes.handle):  MaskBoxYesHnd = GetFocus()

     Form.SHOWMODAL



     SUB GoDirs
      timeBeg=TIMER
      Index=0
      NumFiles=0
      ListView.Clear
      DEFINT nsd1, nsd2
      DEFSTR mask
      nsd1=0
      nsd2=0
      NumDir=0
      ArrNumDir=500
      DIM SubDir(0) AS STRING

      IniDir$ =Edit1.text
      mask="*"

      SubDir(0)=IniDir$


      FOR i=NSD1 TO Nsd2 '¯¥à¥¡šà ¥¬ ¯® €šà¥ªâ®àšï¬ ⥪ã饣® ã஢­ï'
       SubDirname$=DIR$(SubDir(i)+mask, faDirectory)

       WHILE    SubDirname$ <>""
        IF FileRec.Size =0 AND SubDirname$<> "." AND SubDirname$<> ".." THEN ''
         INC adddir
         INC NumDir '€®¡ ¢«ï¥¬ áã¡€šà¥ªâ®àšî'
         IF NumDir=ArrNumDir THEN ArrNumDir=ArrNumDir+300: REDIM SubDir(ArrNumDir) AS STRING
         SubDir(NumDir)=SubDir(i)+SubDirname$+"\"
   'ListView.AddItems SubDir(NumDir)'+"\"+MaskBoxYes.Text
        ELSE
        END IF
        SubDirname$=DIR$
        DOEVENTS:IF stops1=1 THEN stops1=0: EXIT SUB
       WEND
'search files in current subdirectory
       Fn$=DIR$(SubDir(i)+MaskBoxYes.Text,faAnyFile NOT faDirectory) ':-)
       WHILE Fn$ <>""
        IF  Fn$<> "." AND Fn$<> ".." THEN
         INC NumFiles
         fn1$=SubDir(i)+Fn$
''
         IF FILEEXISTS(fn1$)<>0 AND NumFiles<5000 THEN ListView.AddItems Fn1$
        ELSE
        END IF
        Fn$=DIR$
       WEND
       Label1.CAPTION=STR$(NumFiles)
      NEXT i

      IF adddir>0 THEN
       NSD1=NSD2+1 '­ ç «ì­ë© ­®¬¥à €šà¥ªâ®àš© ®ç¥à¥€­®£® ã஢­ï ¢«®Š¥­­®áâš'
       NSD2=NSD2+adddir ''ª®­¥ç­ë© ­®¬¥à €šà¥ªâ®àš© ®ç¥à¥€­®£® ã஢­ï ¢«®Š¥­­®áâš'
       adddir=0
       GOTO 1 '¯®¢â®à塞 á ­®¢ë¬ ã஢­¥¬
      ELSE
      END IF
      timeEnd=TIMER
      Label1.CAPTION="All hits "+STR$(NumFiles)+" "+STR$(timeEnd-timeBeg)+" s"
      SOUND 5000, 1
     END SUB

     SUB  StopS '-- ------------------------'
      StopS1=1
     END SUB

     SUB VisDir(Button%, X%, Y%, Shift%)
      Handle = GetFocus():
      IF handle <> Edit1Hnd THEN DirTree.visible=false
     END SUB

     SUB ChangeDirectory
      Edit1.text=DirTree.Directory
      DirTree.visible=false
     END SUB

     SUB TimerOver
      Form.CAPTION = "RQ GoDirs!                                                  "+dateR+"   "+TIME$
      Handle = GetFocus():
      IF handle=Edit1Hnd  THEN DirTree.visible=true 'else DirTree.visible=false
      IF Handle=RichEdit1.Handle THEN DirTree.visible=false
      IF Handle=MaskBoxYes.Handle THEN DirTree.visible=false

'!!! ------------
     END SUB

掌柜推荐
 
 
¥860.00 ·
 
 
¥410.00 ·
 
 
¥288.00 ·
 
 
¥918.00 ·
 
 
¥288.00 ·
 
 
¥264.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2002-12-24 21:57:56