SyntaxBomb - Indie Coders

Languages & Coding => Blitz Code Archives => File Utilities => Topic started by: BlitzBot on June 29, 2017, 00:28:42

Title: [bb] Filecheck by JPD [ 1+ years ago ]
Post by: BlitzBot on June 29, 2017, 00:28:42
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) Select
;Number of files to check for program
files_count = 4
Dim files$(files_count)

;Filenames
files$(1) = "FILE_01.DAT"
files$(2) = "FILE_02.DAT"
files$(3) = "FILE_03.DAT"
files$(4) = "FILE_04.DAT"

;Check files
For d = 1 To files_count

checkfile = FileType(files$(d))
If checkfile <> 1 RuntimeError "File " + Chr$(34) + files$(d)+Chr$(34) + " doesn't exist!"
;If checkfile <> 1 Notify "File " + Chr$(34) + files$(d)+Chr$(34) + " doesn't exist!"
CloseFile checkfile

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.