Include path.!

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Include path.!

Post by thefool »

Ill just quote myself for an idea i got the other day.
thefool wrote:i think a nice include folder would be nice in purebasic..! where we can put our code then have them directly available in purebasic. then we dont have to put a include file besides every project we have. its pretty annoying sometimes :/
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

I agree! Its a pain in the parse having to copy/paste path names then fiddle with them to include all the files I need to include!
~I see one problem with your reasoning: the fact is thats not a chicken~
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Advertising for this idea :D :
Num3 wrote: WOW! :shock:

Brilliant IDEA !!!
Rescator wrote:And let us change the default (user) includes filepath in the IDE.
I so miss this, as I got several includes that are used in multiple projects. :)
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Killswitch wrote:Its a pain in the parse ..
lol. Too cheeky! :lol:
@}--`--,-- A rose by any other name ..
TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

Re: Include path.!

Post by TerryHough »

thefool wrote:i think a nice include folder would be nice in purebasic..! where we can put our code then have them directly available in purebasic
May I refer you to the PATH command of your operating system?

Win98SE example. Include something like this in your AUTOEXEC.BAT

Code: Select all

PATH C:\;C:\WINDOWS;C:\WINDOWS\COMMAND;C:\PUREBASIC\INCLUDES
On WinXP, the command would be slightly different and would have to be
in your CONFIG.NT file as I recall.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Re: Include path.!

Post by Dare2 »

thefool wrote:Advertising for this idea :D
:D Promote your winning products and services through Jester Media Consultants
TerryHough wrote:May I refer you to the PATH command of your operating system?
Good point. But a default include folder would be nice as well.

(This is a happy customer's endorsement for thefool's idea)
@}--`--,-- A rose by any other name ..
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

@terry: no i didnt know that! but they better tell that then! does it really work?

@dare2: lol :D
btw ever watched the "SaladFingers" series? http://www.fat-pie.com/flash.htm
its sick :S no really his hate mail is funny :D i dunno why i think such things are funny :P
TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

Post by TerryHough »

thefool wrote:@terry: no i didnt know that! but they better tell that then! does it really work?
Sorry, I should have checked first. The IncludeFile and XIncludeFile PB
commands apparently don't follow the defined path. I don't know why.

Generally, OPEN commands do follow the defined path. Maybe these
specific commands don't follow the defined path. (I think PB should).

However, you can implement the idea still by using the
IncludePath "C:\PureBasic\Includes"
prior to issuing any of your Include statements. See the manual for
details.

When I went back and looked, I found my note that the defined path
method didn't work and I had gotten around it as described above.

Sorry, if I confused you. However, it is good to know how the PATH
statement defines Windows reactions anyway.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

it would be ok for me if the compiler just supported the standard path.
the idea with this idea was that we DIDNT have to type anything at all! and that it came with autocomplete like libraries, so we would have minimal work and STILL using source code only.!

However an addition to the idea: the editor should load the autocomplete for the files too! Like with libs just with raw source.!
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

I definetly second these ideas :)
Lebostein
Addict
Addict
Posts: 826
Joined: Fri Jun 11, 2004 7:07 am

Post by Lebostein »

Look here:
viewtopic.php?p=87918
viewtopic.php?t=5995

It's an old problem (request). No statement or comment from PB developers as yet... Currently it's very hard to handle includefiles...
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

hah they didnt even respond to this thread :roll:
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

Well, perhaps if it didn't include subfolders - but I have some code that can scan through directories and their subfolders:

Code: Select all

;\\-----------------------------
;\\-Directory Scanner-----------
;\\-----------------------------

;\\-Notes--
; In a moment of genious I have managed to get this to work! Information on files is stored in the
; File array, while info on directories is stored in the Dir array. The total number of files and
; sub directories are stored in File(0)\Files and Dir(0)\Dirs.
; 
; Parameters
    ;IncludeSubDirs.l ~ If 1 then scan sub directories too. If else then do not.
    ;FullPath.s ~ The full path of the directory to be scanned.
;\\--------

;\\-Structures------------------

Structure FileInfo
  FullPath.s
  SubPath.s
  FileName.s
  Files.l
EndStructure

Structure DirInfo
  SubPath.s
  Dirs.l
  Size.l
EndStructure

;\\-----------------------------

;\\-Arrays----------------------

Dim File.FileInfo(9999999)
Dim Dir.DirInfo(9999999)

;\\-----------------------------

;\\-Procedure-------------------

Procedure ScanDirectory(IncludeSubDirs.l,FullPath.s)

If Right(FullPath,1)<>"\" ;If there isn't a "\" at the end of the string
  FullPath+"\" ;Add the "\"
EndIf

If IncludeSubDirs<>1 ;If SubDirs are not to be included

  If FileSize(FullPath)=-2 ;If directory exists
    ExamineDirectory(0,FullPath,"*.*")
    Repeat
      Select NextDirectoryEntry()
        Case 0
          StopLoop=1
        Case 1
          Files+1
          File(Files)\FullPath=FullPath+DirectoryEntryName()
          File(Files)\FileName=DirectoryEntryName()
          Dir(0)\Size+FileSize(FullPath+DirectoryEntryName())
      EndSelect
    Until StopLoop=1
    File(0)\Files=Files
    ProcedureReturn 1
  Else ;If it does not
    ProcedureReturn 0
  EndIf

EndIf
  

For t=2 To Len(FullPath) ;Cycle through the characters, from second last to start
  SubPart.s=Right(FullPath,t) ;Get the next part of the string
  PathPart.s=Left(FullPath,Len(FullPath)-t+1)
  If Mid(SubPart,1,1)="\" ;If the first character equals '\'
    RootPath.s=PathPart
    SubPath.s=Right(FullPath,t-1) ;Sub path = 2nd chr of Part to last Chr
    Break  
  EndIf
Next t

If FileSize(FullPath.s)=-2 ;If directory exists
  
  ExamineDirectory(0,FullPath,"*.*")
  
  Dir(0)\SubPath=SubPath
  
  Repeat
    
    UseDirectory(Actual)
    
    Repeat
      
      Select NextDirectoryEntry()
      
        Case 0 ;If there are no more files/directorys
          DirFinished=1
        
        Case 1 ;Next entry is a file
          FileName.s=DirectoryEntryName()
          If FileName.s<>OldFileName.s
            
            Files+1
            
            If Right(Dir(Actual)\SubPath,1)="\" ;If the last chr is "\"
              Add.s=FileName ;Don't add a slash
            Else ;If there is no slash
              Add.s="\"+FileName ;Add a slash
            EndIf
            
            File(Files)\FullPath=RootPath+Dir(Actual)\SubPath+Add
            File(Files)\SubPath=Dir(Actual)\SubPath+Add
            File(Files)\FileName=FileName
            Dir(0)\Size+FileSize(RootPath+Dir(Actual)\SubPath+Add)
            
            OldFileName.s=FileName
          
          EndIf
          
        Case 2 ;Next entry is a directory
          DirName.s=DirectoryEntryName()
            
            If DirName<>"." And DirName<>".." ;First two results are always "." and ".." ignore them
              DirsToScan+1 ;Number of directories to scan has increased by one
              
              If Right(Dir(Actual)\SubPath,1)="\" ;If the last chr is "\"
                Add.s=DirName ;Don't add a slash
              Else ;If there is no slash
                Add.s="\"+DirName ;Add a slash
              EndIf
              
              Dir(DirsToScan)\SubPath=Dir(Actual)\SubPath+Add ;New subpath
              
              If ExamineDirectory(DirsToScan,RootPath+Dir(DirsToScan)\SubPath,"*.*") ;Scan directory
                UseDirectory(Actual)
              EndIf 
            EndIf
      
      EndSelect
      
    
    Until DirFinished=1
    
    Actual+1
    DirFinished=0
    
    If Actual>DirsToScan
      File(0)\Files=Files
      Dir(0)\Dirs=DirsToScan
      FinishedScan=1
    EndIf
    
  Until FinishedScan=1
    
  ProcedureReturn 1
Else ;Directory does not exist
  ProcedureReturn 0
EndIf


EndProcedure




;\\-----------------------------
~I see one problem with your reasoning: the fact is thats not a chicken~
Lebostein
Addict
Addict
Posts: 826
Joined: Fri Jun 11, 2004 7:07 am

Post by Lebostein »

Killswitch wrote:Well, perhaps if it didn't include subfolders - but I have some code that can scan through directories and their subfolders:

Code: Select all

.....
Dim File.FileInfo(9999999)
Dim Dir.DirInfo(9999999)
...
How about LinkedLists?
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

Linked lists confuse me, so I'll stick with arrays - I was just showing that it isn't that hard to read files from a directory.
~I see one problem with your reasoning: the fact is thats not a chicken~
Post Reply