Algorithm glitch?

Blitz3D Forums/Blitz3D Programming/Algorithm glitch?

Guy Fawkes(Posted 2009) [#1]
Hi all. Can someone help me fix this so it detects when its done listing all the files, and use that to bring up an error message ONLY IF the file$ variable does NOT include the right files inside this if command?

If command:



actual code:




Guy Fawkes(Posted 2009) [#2]
I basically want it to read all the files, detect if its DONE READING the list of files, and if it finds a file or folder that is NOT in the list, then activate error message and end the program


GfK(Posted 2009) [#3]
I basically want it to read all the files, detect if its DONE READING the list of files, and if it finds a file or folder that is NOT in the list, then activate error message and end the program
You mean, like you said in your first post which I managed to read quite adequately without you reposting the same thing again and typing some different random words in capital letters?

Seriously - give people chance to reply. People don't visit the forum solely to serve you, so it might take more than eleven minutes to get an answer sometimes.


Matty(Posted 2009) [#4]
This code is taken almost directly from the blitz3d documentation on the 'nextfile' command.

; ReadDir/NextFile$/CloseDir example

; Define what folder to start with ...set this yourself...
folder$="C:"

; Open up the directory, and assign the handle to myDir
myDir=ReadDir(folder$)

; Let's loop forever until we run out of files/folders to list!
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 

If file$ <> "." And file$ <> ".." And file$ <> "Characters" And file$ <> "Music" And file$ <> "Media" And file$ <> "fonts" And file$ <> "Textures" And file$ <> "Objects" And file$ <> "Sounds" And file$ <> "Stages" And file$ <> "Interface" And file$ <> "logo.png" And file$ <> "Controls README.txt" And file$ <> "Readme.txt" And file$ <> "FastImage.dll" And file$ <> "Blitz3DA.dll" And file$ <> "DirectX7A.dll" And file$ <> "License.txt" And file$ <> "Config.xml" And file$ <> "main.exe" And file$ <> "Security.bb" And file$ <> "start.bb" And file$ <> "particle candy.bb" And file$ <> "particle types.bb" And file$ <> "main.bb" And file$ <> "_SourceCode" And file$ <> "Security.bb" And file$ <> CurrentDir$() Then
	RuntimeError("Not one of the files we were expecting")
EndIf 

Forever

; Properly close the open folder
CloseDir myDir

; We're done!
Print "Done listing files!"




LineOf7s(Posted 2009) [#5]
Welcome back Rez. Happy New Year!


Guy Fawkes(Posted 2009) [#6]
Thanks LineOf7s, same to you! and thanks matty! ^^


Guy Fawkes(Posted 2009) [#7]
Um, Matty? It's supposed to list all the files that ARENT in the if command, then it needs a variable to detect if it's done reading the list of files.


JA2(Posted 2009) [#8]
Rez, you came back!? We missed you so much!


Guy Fawkes(Posted 2009) [#9]
Yea. I came back. I figure, if I stay, it will annoy you more, so yes, I'm GLAD to be back.


Matty(Posted 2009) [#10]
; ReadDir/NextFile$/CloseDir example

;ML Added List object
Type FileListObject
	
	Field FileName$
	
End Type

; Define what folder to start with ...set this yourself...
folder$="C:"

; Open up the directory, and assign the handle to myDir
myDir=ReadDir(folder$)

; Let's loop forever until we run out of files/folders to list!
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 

If file$ <> "." And file$ <> ".." And file$ <> "Characters" And file$ <> "Music" And file$ <> "Media" And file$ <> "fonts" And file$ <> "Textures" And file$ <> "Objects" And file$ <> "Sounds" And file$ <> "Stages" And file$ <> "Interface" And file$ <> "logo.png" And file$ <> "Controls README.txt" And file$ <> "Readme.txt" And file$ <> "FastImage.dll" And file$ <> "Blitz3DA.dll" And file$ <> "DirectX7A.dll" And file$ <> "License.txt" And file$ <> "Config.xml" And file$ <> "main.exe" And file$ <> "Security.bb" And file$ <> "start.bb" And file$ <> "particle candy.bb" And file$ <> "particle types.bb" And file$ <> "main.bb" And file$ <> "_SourceCode" And file$ <> "Security.bb" And file$ <> CurrentDir$() Then
	;RuntimeError("Not one of the files we were expecting")
	;ML Added To Collect File Names
	FLO.FileListObject=New FileListObject
	FLO\FileName=file$

EndIf 

Forever

; Properly close the open folder
CloseDir myDir

; We're done! 

;ML Added Print out of list
For FLO.FileListObject=Each FileListObject
	Print FLO\FileName
Next
Delete Each FileListObject
Print "Done listing files!"




Guy Fawkes(Posted 2009) [#11]
thanks matty, but how does that detect if it's done listing files with a variable?


Matty(Posted 2010) [#12]
If file$="" then exit ;if the end of the list is reached your variable 'file$' will be empty.