Page 1 of 2

Posted: Tue Oct 01, 2002 7:59 pm
by BackupUser
Restored from previous forum. Originally posted by altesocke.

hi forum,

i use UseDirectory() in a recursive procedure, and the debugger tells
me "#FileSystem object not initialised".

does anyone know why that is so?

here is my code:

Code: Select all

#Window1 = 1
#W1Btn1 = 1
#Window1Flags = #PB_Window_MinimizeGadget | #PB_Window_SystemMenu

Structure DIRS
 dirhandle.l
 fullpath.s
EndStructure 

NewList dirlist.DIRS()

Procedure ReadPath(path$, dir_num)
Debug dir_num
 If ExamineDirectory(dir_num, path$, "*.*")
  openflag.l = #TRUE	
  Repeat
   FileType = NextDirectoryEntry() 
   FileName$ = DirectoryEntryName()      
  If FileType = 2
   If FileName$  "." And FileName$  ".."
    AddElement(dirlist())
     fullpath$ = path$+FileName$+"\"
     dirlist()\fullpath = fullpath$ 
     ReadPath(fullpath$, dir_num+1)
     UseDirectory(dir_num)					
    EndIf 
   EndIf  
  Until FileType = 0	
 EndIf
EndProcedure

hwnd = OpenWindow( #Window1, 300,300,100,100, #Window1Flags,"test")

 If CreateGadgetList(WindowID(1))
    ButtonGadget(#W1Btn1,1,1 ,89,25,"Choose Dir")
 EndIf
  
 Repeat
 Delay(1)
 EventID.l = WaitWindowEvent()
		
 Select EventID
		
 Case #PB_EventGadget
 Select EventGadgetID()
 Case #W1Btn1
 ClearList(dirlist())
 app_path$ = PathRequester("Application Path", "c:\")		
 If app_path$  ""		
 dir_num = 1
 ReadPath(app_path$, dir_num)
res = CountList(dirlist())
Debug res
 EndIf               	
		
 EndSelect
		    
 EndSelect
	
 Until EventID = #PB_EventCloseWindow

End
thx, socke

Posted: Tue Oct 01, 2002 9:54 pm
by BackupUser
Restored from previous forum. Originally posted by Pupil.

Seems to be a debugger problem, if you disable the debugger around the procedure, like this:

Code: Select all

DisableDebugger
Procedure ReadPath(path$, dir_num)
  ...
EndProcedure
EnableDebugger
You'll see that it works OK.

Posted: Tue Oct 01, 2002 10:06 pm
by BackupUser
Restored from previous forum. Originally posted by Franco.

No error messages on Win2000-Sp3

Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.

Posted: Tue Oct 01, 2002 10:09 pm
by BackupUser
Restored from previous forum. Originally posted by PB.

> Seems to be a debugger problem, if you disable the debugger around
> the procedure [...] you'll see that it works OK.

Nope, the bug occurs because altesocke is starting the recurse with a
dir_num setting of 1, when it should be 0. Change it to 0 and it works.
You should never have to disable the debugger to get something working.


PB - Registered PureBasic Coder

Posted: Wed Oct 02, 2002 7:45 am
by BackupUser
Restored from previous forum. Originally posted by Pupil.
Originally posted by PB
Nope, the bug occurs because altesocke is starting the recurse with a
dir_num setting of 1, when it should be 0. Change it to 0 and it works.
You should never have to disable the debugger to get something working.
I really can't see how this could be a bug, should work with ANY start numbers. In the example you never ever use a Directory number that is not previously Examined so why would changing the start number break the code. The manual says nothing about having to start from '0', maybe it should.
@Franco, you did compile with debugger on, didn't you?

Posted: Wed Oct 02, 2002 8:43 am
by BackupUser
Restored from previous forum. Originally posted by fred.

There is a bug, thanks. Fixed now, for v3.40.

Fred - AlphaSND

Posted: Wed Oct 02, 2002 11:15 am
by BackupUser
Restored from previous forum. Originally posted by PB.

> I really can't see how this could be a bug, should work with ANY
> start numbers.

I've always used a starting dir of 0 in my own apps which is why I
thought it must have been a bug (ie. starting with 1). I had always
assumed that 0 meant the first level of recurse, with 1 being the
next, and so on. Changing 1 to 0 in altesocke's code fixed the problem,
thus causing me to believe I was right -- when I was in fact wrong,
as shown by Fred stating that a bug does exist. I stand corrected.

PB - Registered PureBasic Coder

Posted: Wed Oct 02, 2002 12:08 pm
by BackupUser
Restored from previous forum. Originally posted by altesocke.

thx, i got it to work with starting at 0.

socke

Posted: Wed Oct 02, 2002 3:19 pm
by BackupUser
Restored from previous forum. Originally posted by Pupil.
Originally posted by PB

> I really can't see how this could be a bug, should work with ANY
> start numbers.

I've always used a starting dir of 0 in my own apps which is why I
thought it must have been a bug (ie. starting with 1). I had always
assumed that 0 meant the first level of recurse, with 1 being the
next, and so on. Changing 1 to 0 in altesocke's code fixed the problem,
thus causing me to believe I was right -- when I was in fact wrong,
as shown by Fred stating that a bug does exist. I stand corrected.
Well, you input was good as it helped Altesocke to get his code to work with the current iteration of PureBasic and you also provided, i think, valuable tips on good coding style(i.e. starting at 0).
I think these sort of discussions are good, because we get a better programing language with less and less bugs in it;)

Posted: Wed Oct 02, 2002 3:22 pm
by BackupUser
Restored from previous forum. Originally posted by fred.

Bugs tends to be rare these days... They are affraid ! :)

Fred - AlphaSND

Posted: Wed Oct 02, 2002 3:47 pm
by BackupUser
Restored from previous forum. Originally posted by Pupil.
Originally posted by fred

Bugs tends to be rare these days... They are affraid ! :)
In the Bug Report section there is another one to scare off :wink:

Posted: Wed Oct 02, 2002 4:01 pm
by BackupUser
Restored from previous forum. Originally posted by Franco.
Originally posted by Pupil
Originally posted by PB
@Franco, you did compile with debugger on, didn't you?
Yes I did...
Does anybody had this bug with the same OS :) (Win2000-Sp3)

Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.

Posted: Wed Oct 02, 2002 4:12 pm
by BackupUser
Restored from previous forum. Originally posted by Franco.
Originally posted by fred

Bugs tends to be rare these days... They are affraid ! :)

Fred - AlphaSND

...speaking about bugs, Fred could I send you my code of my game and you take a look at it :)


There is a bug regarding WinXP and when my game starts with level one (there is a base level {level 0}) the CPU usage is jumping from 25% to 100% and the keyboard keys are acting very slow.

No bug occures in Win2000 - that's the strange part.

Figured out that when I close a Windowed Screen and open another Windowed Screen, there is a second main window, for a very short period of time (only on WinXP NOT on Win2000).
So I suppose there is a bug in the 'OpenWindowedScreen' function while running under WinXP.

@others:
Sorry I'm off topic again...


Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.

Posted: Wed Oct 02, 2002 4:51 pm
by BackupUser
Restored from previous forum. Originally posted by Pupil.
Originally posted by Franco
Originally posted by Pupil
Originally posted by PB
@Franco, you did compile with debugger on, didn't you?
Yes I did...
Strange, did the directory you selected have directorys inside it?

Anyway altesocke got it to work so it really doesn't matter.

Posted: Wed Oct 02, 2002 4:54 pm
by BackupUser
Restored from previous forum. Originally posted by Franco.
Originally posted by Pupil
Originally posted by Franco
Originally posted by Pupil
Originally posted by PB
@Franco, you did compile with debugger on, didn't you?
Yes I did...
Strange, did the directory you selected have directorys inside it?
NOP! Thanks Pupil, now I can see the light :)

Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.