TGC Codebase Backup



add multiple media files to your dba programme by jayell leedham

8th May 2008 2:11
Summary

Place large numbers of media "load sound " ",1 etc statements into your dba programme by copying and pasting.



Description

If you have to type in a lot of statements such as load sound "ding.wav",1 etc (80 of them in my case), you can avoid that with this programme. Just put your files in a separate directory, alter the programme s commented, if necessary, to suit your media type, and the copy and paste the resultant text programme As is, it is written for .wav files.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    gosub setup
for nn=1 to numoffiles-2
   name$=get file name$()
   Rem store the filenames in the array
   filelist$(nn)=name$
   find next
next nn
Rem this is the directory to hold the filelist (not the same as the source of the filelist!
set dir "c:dbprowords"
while file exist ("allfiles.txt")
   delete file "allfiles.txt"
endwhile
open to write 2, "allfiles.txt"
for nn=1 to numoffiles-2 step 3
   Rem change these lines to suit the command needed
   Rem the result will be lines of 3 commands, with ":" where needed
   name$="load sound "+chr$(34)+filelist$(nn)+chr$(34)+","+str$(nn)+":"
   if nn=numoffiles-2
      name$="load sound "+chr$(34)+filelist$(nn)+chr$(34)+","+str$(nn)
      goto gg
   endif
   if nn+2<=numoffiles-2
      name$=name$+"load sound "+chr$(34)+filelist$(nn+1)+chr$(34)+","+str$(nn+1)+":"
      name$=name$+"load sound "+chr$(34)+filelist$(nn+2)+chr$(34)+","+str$(nn+2)
      goto gg
   endif
   if nn+1=numoffiles-2
      name$=name$+"load sound "+chr$(34)+filelist$(nn+1)+chr$(34)+","+str$(nn+1)
   endif
   gg:
      write string 2,name$
   next nn
   close file 2
   end

   setup:
      Rem this directory contains all the files you want to copy
      set dir "c:dbprowordsdifficult"
      Rem set the dim to be the same or more than the number of files
      dim filelist$(100)
      perform checklist for files
      numoffiles=checklist quantity()
      find first:find next:find next
   return