B3D wont update the directory!

Blitz3D Forums/Blitz3D Programming/B3D wont update the directory!

Crinkle(Posted 2011) [#1]
Ok i have this function which is:

Function dir_scan$(folder$)
	dc=1
	myDir=ReadDir(folder$)
	Repeat
		; Assign the next entry in the folder to file$
		file$=NextFile$(myDir)

		; If there isn't another one, let's exit this loop
		If file$="" Then Exit

		; Use FileType to determine if it is a folder (value 2) or a file and print results
		If FileType(folder$+"\"+file$) = 2 And file$<>"." And file$<>".." Then 
			DB_Dir$(dc)=file$
			dc=dc+1
		EndIf
		
	Forever
	
	browse_dir_dir_count=dc-1
End Function


Which scans the given folder in the function variable and if the item it finds is a folder adds it to the DB_Dir$ list, however for some reason this function can only be run once, and after that it doesn't update the array, Why?


Beaker(Posted 2011) [#2]
You probably need to use CloseDir().

Last edited 2011


Crinkle(Posted 2011) [#3]
Nope it still doesn't seem to update, it runs all the code i tested it with a run time error, it just isn't updating the directorys :?


Crinkle(Posted 2011) [#4]
Aha, found the error! It wasn't that the code wasn't working, it just didn't CLEAR the database of folder names, so subsequently if a subfolder contained no folders to overwrite the previous ones the same ones would be displayed.