/* Dos Boot Tape Builder */

/* no error checking */

fname = "V95"                              /* File prefixes */

nofls = 11                                 /* Number of fls */
dosln = 14                                 /* Label  length */
stfln = 512                                /* Data   length */
bootb = 2062                               /* Bootblklength */

label = x2c('0e 00 00 00')                 /* Label  length */
stuff = x2c('00 02 00 00')                 /* Data   length */
botlb = x2c('0e 08 00 00')                 /* Bootblklength */
eofmk = x2c('00 00 00 00')                 /* Eof    record */

error = open(outfile,"ram:"fname".tap",'W')

do i = 1 to nofls                          /* Files 001-999 */
   ext   = right("000"i,3)                 /* File trailer  */
   say     fname"."ext                     /* Announce it   */
   error = open(infile,fname"."ext,'R')    /* Open it       */
   if i  = 1 then do                       /* Boot block?   */
      raw   = readch(infile,bootb)         /* Get boot block*/
      error = writech(outfile,botlb)       /* SOH Record    */
      error = writech(outfile,raw)         /* Put header    */
      error = writech(outfile,botlb)       /* End of Record */
      end
   else do
      raw   = readch(infile,dosln)         /* Get header    */
      error = writech(outfile,label)       /* SOH Record    */
      error = writech(outfile,raw)         /* Put header    */
      error = writech(outfile,label)       /* End of Record */
      end

   do until eof(infile)
      raw   = readch(infile,stfln)         /* Get stuff     */
      if length(raw) = stfln then do       /* Anything?     */
         error = writech(outfile,stuff)    /* Record length */
         error = writech(outfile,raw)      /* Put record    */
         error = writech(outfile,stuff)    /* Record length */
      end
   end
   error = writech(outfile,eofmk)          /* End of file   */
   call close infile
end

error = writech(outfile,eofmk)             /* End of tape   */
error = writech(outfile,eofmk)             /* End of tape   */

call close outfile
