November 25, 2020, 08:06:03 AM

Author Topic: [bb] BlitzPlus File Explorer by assari [ 1+ years ago ]  (Read 602 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] BlitzPlus File Explorer by assari [ 1+ years ago ]
« on: June 29, 2017, 12:28:40 AM »
Title : BlitzPlus File Explorer
Author : assari
Posted : 1+ years ago

Description : Uses recursive function to add folders and selected files into a treeview gadget.

Code :
Code: BlitzBasic
  1. ; B+ program to populate a treeview gadget with folders and files
  2. ; Author: Assari
  3. ; Created: 16th March 2003
  4. ;
  5.  
  6. Global window=CreateWindow("B+ program to populate a treeview gadget with folders and files",0,0,800,600)
  7. treeview=CreateTreeView( 0,0,ClientWidth(window),ClientHeight(window),window )
  8. SetGadgetLayout treeview,1,2,2,2
  9. root=TreeViewRoot( treeview )
  10.  
  11. folderlist$=RequestDir("Pls Select Folder")
  12.  
  13. If folderlist$>"" And Right$(folderlist$,1)="" Then ;remove any
  14.    folderlist$=Left$(folderlist$,Len(folderlist$)-1)
  15. EndIf
  16.  
  17. node=AddTreeViewNode(FolderList$,root)
  18.  
  19. TrawlFolder(FolderList$,"root",".JPG JPEG .BMP .PNG .ZIP",node)
  20.  
  21. Repeat
  22.  WaitEvent()
  23.  If EventID()=$803 Then End
  24. Forever
  25.  
  26. End
  27.  
  28.  
  29. Function TrawlFolder(CurrentPath$, CurrentParent$, Pattern$, ParentNode)
  30.  
  31.     If CurrentParent$="root" Then
  32.        CurrentParent$=CurrentPath$
  33.        xPath$=CurrentPath$
  34.     Else
  35.       xPath$=CurrentPath$+""+CurrentParent$
  36.     EndIf
  37.  
  38.   hDir = ReadDir(xPath$):If hDir=0 Then Return ;no more folders
  39.  
  40.   Repeat
  41.  
  42.     File$=NextFile(hDir):If File$="" Then Return ;no more files
  43.  
  44.     Select FileType(xPath$+""+file$)
  45.       Case 2 ;folder
  46.         If Not (file$="." Or Right$(file$,2)="..") Then
  47.           node=AddTreeViewNode(">"+file$,ParentNode)
  48.           TrawlFolder(xPath$,File$,Pattern$, Node)   ;recursion required here
  49.         EndIf
  50.      Case 1 ;file
  51.         ext$=Upper$(Right$(file$,4)) ;check for extension (last four characters)
  52.         If Instr(pattern$,ext$) Then
  53.            node=AddTreeViewNode(file$,ParentNode)
  54.         EndIf
  55.     End Select
  56.  
  57.     ;the next two lines are not required
  58.     SetStatusText window, CurrentParent$+""+file$ ;just to let the world know we're working
  59.     WaitEvent(1):If EventID()=$103 And EventData()=27 Then Return;Escape route
  60.  
  61.   Forever
  62.  
  63. End Function


Comments :


modmcdl(Posted 1+ years ago)

 How can you set it so that it starts out at a certain folder?For example: C:DOCTRINECorePluginsPersonalProfile


modmcdl(Posted 1+ years ago)

 that is for a program im creating, i just want to know where to put the directory


Pakz(Posted 1+ years ago)

 I think if I read it right that you need to use the variable folderlist$ to set that.


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal