Page 1 of 1

Pb src Folder Loader

Posted: Sun Nov 30, 2008 9:24 pm
by idle
Quick n dirty hack: pb src folder Loader Windows only

credit to KCC (for his question) and #Null's (tips)

Note: it should Backup your PureBasic.prefs file but you may do so your self before you run it.

documents and settings->(useraccount)->applicationdata->purebasic...

I don't know if it'll work on vista so please fix if it doesn't

Create the exe to your desktop or where ever then just drag a folder onto it. It will open all the pb src files in the folder and its sub directories.

To open only the files in a particular folder with no recursion, open folder and drag a file onto the loader.

To open Pb up normally with your last settings just double click

additionally create a short cut on the desktop and one in your sendto folder.

Code: Select all

 

Procedure.s GetSpecialFolderLocation(Value.l)
  If SHGetSpecialFolderLocation_(0, Value, @File_ID) = 0
    SpecialFolderLocation.s = Space(#MAX_PATH)
    SHGetPathFromIDList_(File_ID, @SpecialFolderLocation)
    If SpecialFolderLocation
      If Right(SpecialFolderLocation, 1) <> "\"
        SpecialFolderLocation + "\"
      EndIf
    EndIf
  EndIf
  ProcedureReturn SpecialFolderLocation.s
EndProcedure

Procedure NukeSettings(filepath.s,strWorkPath.s)

Protected strpath.s

If OpenPreferences(filepath + "PureBasic\PureBasic.prefs")
    PreferenceGroup("FolderLaunch")
    If ReadPreferenceLong("Backedup", 0) = 0
       WritePreferenceLong("Backedup", 1)
       CopyFile(filepath + "PureBasic\PureBasic.prefs",filepath + "PureBasic\PureBasic_Back.prefs")
    EndIf
    RemovePreferenceGroup("OpenedFiles")
    PreferenceGroup("Global")
    strpath = ReadPreferenceString("SourceDirectory", "")
    If strpath <> strWorkPath
       WritePreferenceString("SourceDirectory",strWorkPath +"\")
       PreferenceGroup("Explorer")
       WritePreferenceString("Path",strWorkPath +"\")
       PreferenceGroup("FileViewer")
       WritePreferenceString("Path",strWorkPath +"\")
    EndIf
    ClosePreferences()
EndIf     
EndProcedure

Procedure.s dirlist(dir.s,bRec=0)
  Static strFiles.s
  Static ct1
  mDir = ExamineDirectory(#PB_Any, dir, "*.*") 
  If mDir 
    While NextDirectoryEntry(mDir)
      If DirectoryEntryType(mDir) = #PB_DirectoryEntry_File
          Directory$ = dir
          FileName.s = DirectoryEntryName(mDir)
          If FindString(FileName,".pb", 1)
            FullFileName.s = dir + "\" + FileName
            Debug FullFileName
            strFiles + Chr(34) + FullFileName + Chr(34) 
            ct1+1
          EndIf   
      Else
         tdir$ = DirectoryEntryName(mDir)
         If tdir$ <> "." And tdir$ <> ".."
           If bRec = 0
           dirlist(Dir + "\" + tdir$)
           EndIf
         EndIf
      EndIf
   Wend
   FinishDirectory(mDir)
  EndIf
 
  ProcedureReturn strFiles

EndProcedure



filepath.s = GetSpecialFolderLocation(26)

If filepath
   tdir$ = ProgramParameter()
   If FindString(tdir$,".pb",1)
      tdir$= GetPathPart(tdir$)
      recursive = 1
   EndIf   
   If tdir$ <> ""
      NukeSettings(filepath,tdir$)
      param$ = dirlist(tdir$,recursive)
           
   EndIf     
EndIf



RunProgram(#PB_Compiler_Home+"purebasic.exe",param$,".\")

Posted: Tue Dec 02, 2008 10:55 am
by Kwai chang caine
Very very cool 8)
Thank you very much IDLE