Page 1 of 1
Include path.!
Posted: Mon Aug 15, 2005 3:29 pm
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 :/
Posted: Mon Aug 15, 2005 3:39 pm
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!
Posted: Mon Aug 15, 2005 3:41 pm
by thefool
Advertising for this idea

:
Num3 wrote:
WOW!
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.

Posted: Mon Aug 15, 2005 3:52 pm
by Dare2
Killswitch wrote:Its a pain in the parse ..
lol. Too cheeky!

Re: Include path.!
Posted: Mon Aug 15, 2005 4:08 pm
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.
Re: Include path.!
Posted: Mon Aug 15, 2005 4:20 pm
by Dare2
thefool wrote:Advertising for this idea
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)
Posted: Mon Aug 15, 2005 4:36 pm
by thefool
@terry: no i didnt know that! but they better tell that then! does it really work?
@dare2: lol

btw ever watched the "SaladFingers" series?
http://www.fat-pie.com/flash.htm
its sick :S no really his hate mail is funny

i dunno why i think such things are funny

Posted: Mon Aug 15, 2005 5:19 pm
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.
Posted: Mon Aug 15, 2005 5:28 pm
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.!
Posted: Mon Aug 15, 2005 8:27 pm
by Rescator
I definetly second these ideas

Posted: Tue Aug 16, 2005 8:26 am
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...
Posted: Wed Aug 17, 2005 7:03 pm
by thefool
hah they didnt even respond to this thread :roll:
Posted: Wed Aug 17, 2005 8:15 pm
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
;\\-----------------------------
Posted: Thu Aug 18, 2005 6:57 am
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?
Posted: Thu Aug 18, 2005 7:59 am
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.