Algorithm glitch?
Blitz3D Forums/Blitz3D Programming/Algorithm glitch?
| ||
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: |
| ||
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 |
| ||
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. |
| ||
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!" |
| ||
Welcome back Rez. Happy New Year! |
| ||
Thanks LineOf7s, same to you! and thanks matty! ^^ |
| ||
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. |
| ||
Rez, you came back!? We missed you so much! |
| ||
Yea. I came back. I figure, if I stay, it will annoy you more, so yes, I'm GLAD to be back. |
| ||
; 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!" |
| ||
thanks matty, but how does that detect if it's done listing files with a variable? |
| ||
If file$="" then exit ;if the end of the list is reached your variable 'file$' will be empty. |