NextFile.htm 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <html>
  2. <head>
  3. <title>Blitz3D Docs</title>
  4. <link rel=stylesheet href=../css/commands.css type=text/css>
  5. </head>
  6. <body>
  7. <h1>NextFile$ (filehandle)</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. filehandle = valid filehandle assigned from the ReadDir command
  13. </td>
  14. </tr>
  15. </table>
  16. <h1>Description</h1>
  17. <table>
  18. <tr>
  19. <td>
  20. This command will return the NEXT file or folder from the currently open directory (use ReadDir to open the desired folder for reading). This will return a string containing the folder name or the filename plus extention. Use FILETYPE to determine if it is a file or folder. See ReadDir and CloseDir for more. You cannot move 'backwards' through a directory, only forward. You might want to parse the contents of a directory into an array for display, processing, etc.
  21. </td>
  22. </tr>
  23. </table>
  24. <h1><a href=../2d_examples/NextFile.bb>Example</a></h1>
  25. <table>
  26. <tr>
  27. <td>
  28. ; ReadDir/NextFile$/CloseDir example <br />
  29. <br />
  30. ; Define what folder to start with ... <br />
  31. folder$="C:" <br />
  32. <br />
  33. ; Open up the directory, and assign the handle to myDir <br />
  34. myDir=ReadDir(folder$) <br />
  35. <br />
  36. ; Let's loop forever until we run out of files/folders to list! <br />
  37. Repeat <br />
  38. ; Assign the next entry in the folder to file$ <br />
  39. file$=NextFile$(myDir) <br />
  40. <br />
  41. ; If there isn't another one, let's exit this loop <br />
  42. If file$="" Then Exit <br />
  43. <br />
  44. ; Use FileType to determine if it is a folder (value 2) or a file and print results <br />
  45. If FileType(folder$+"\"+file$) = 2 Then <br />
  46. Print "Folder:" + file$ <br />
  47. Else <br />
  48. Print "File:" + file$ <br />
  49. End If <br />
  50. Forever <br />
  51. <br />
  52. ; Properly close the open folder <br />
  53. CloseDir myDir <br />
  54. <br />
  55. ; We're done! <br />
  56. Print "Done listing files!"
  57. </td>
  58. </tr>
  59. </table>
  60. <br>
  61. <a target=_top href=../index.htm>Index</a><br>
  62. <br>
  63. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=NextFile&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  64. </html>