TGC Codebase Backup



Writing Existing File Numbers to a File by John H

12th Oct 2003 17:49
Summary

This will write the file number to the file "exist.txt" which is created in the same directory as your project file. It will write to the file if a a model, image, sprite



Description

When you open the exist.txt file, you will see all the file types and numbers existing in your program in the following format

Model: (model number)

This process will repeat for all model numbers that exist. This is the same for any other file types. To add your check it is simple. Simply copy this code

for n=1 to 100
if sprite exist(n)
write string 1,"Sprite: "+str$(n)
endif
next n

And change the following

n to another variable
Sprite Exist() to whatever file type you wish to check for.

Enjoy

RPGamer



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    REM Put this after any loading/creating commands. Do not put this in the loop. I take no
REM responsibility for any damage caused to your system by using this code. 

 if file exist("exist.txt") then delete file "exist.txt"

   open to write 1,"exist.txt"

   write string 1,"         Models         "
   write string 1,"------------------------"
   write string 1," "
      for i=1 to 100
         if object exist(i)
            write string 1,"Model: "+str$(i)
            else
            write string 1,"OPEN: "+str$(i)
         endif
      next i

      write string 1," "

   write string 1,"         Images         "
   write string 1,"------------------------"
   write string 1," "
      for j=1 to 100
         if image exist(j)
            write string 1,"Image: "+str$(j)
            else
            write string 1,"OPEN: "+str$(j)
         endif
      next j

      write string 1," "

   write string 1,"          Music         "
   write string 1,"------------------------"
   write string 1," "
      for k=1 to 100
         if music exist(k)
            write string 1,"Music: "+str$(k)
            else
            write string 1,"OPEN: "+str$(k)
         endif
      next k

      write string 1," "

   write string 1,"         Sounds         "
   write string 1,"------------------------"
   write string 1," "
      for l=1 to 100
         if sound exist(l)
            write string 1,"Sound: "+str$(l)
            else
            write string 1,"OPEN: "+str$(l)
         endif
      next l

      write string 1," "

   write string 1,"        Matrices        "
   write string 1,"------------------------"
   write string 1," "
      for m=1 to 100
         if matrix exist(m)
            write string 1,"Matrix: "+str$(m)
            else
            write string 1,"OPEN: "+str$(m)
         endif
      next m

      write string 1," "

   write string 1,"         Sprites        "
   write string 1,"------------------------"
   write string 1," "
      for n=1 to 100
         if sprite exist(n)
            write string 1,"Sprite: "+str$(n)
            else
            write string 1,"OPEN: "+str$(n)
         endif
      next n

   close file 1