Ooops
November 25, 2020, 05:25:16 AM

Author Topic: [bb] Filecheck by JPD [ 1+ years ago ]  (Read 528 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Filecheck by JPD [ 1+ years ago ]
« on: June 29, 2017, 12:28:42 AM »
Title : Filecheck
Author : JPD
Posted : 1+ years ago

Description : Use this code to check all files of your game. If any file doesn't exist, you can abort the programm or notify about the missing file. Enter this code at the beginning of your application.

Code :
Code: BlitzBasic
  1. ;Number of files to check for program
  2. files_count = 4
  3. Dim files$(files_count)
  4.  
  5. ;Filenames
  6. files$(1) = "FILE_01.DAT"
  7. files$(2) = "FILE_02.DAT"
  8. files$(3) = "FILE_03.DAT"
  9. files$(4) = "FILE_04.DAT"
  10.  
  11. ;Check files
  12. For d = 1 To files_count
  13.  
  14. checkfile = FileType(files$(d))
  15. If checkfile <> 1 RuntimeError "File " + Chr$(34) + files$(d)+Chr$(34) + " doesn't exist!"
  16. ;If checkfile <> 1 Notify "File " + Chr$(34) + files$(d)+Chr$(34) + " doesn't exist!"
  17. CloseFile checkfile
  18.  
  19. Next


Comments :


Warren(Posted 1+ years ago)

 An easier way to go would be to wrap your "file open" and "load" commands in your own function that checks the return value and aborts if the file isn't there.Constantly updating a list like this at the start of your game is just asking for trouble.  The odds of forgetting to add one are astronomical.


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal