home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / b / vmsbak.bas < prev    next >
BASIC Source File  |  2020-01-01  |  3KB  |  90 lines

  1. 1!    KERMITFIX.BAS - VAX BASIC                    &
  2. !    Written by Gary Stebbins, Digital Equipment Corporation        &
  3. !    Convert VMS Backup-format files to fixed 512 records and back    &
  4. !                                    &
  5. !   restriction:                            &
  6. !    requires backup save_set recordsize to be a multiple of 512    &
  7. !    (some tape save_sets don't meet this requirement)        &
  8. !                                    &
  9. !  to use:                                &
  10. !    o create a backup save_set of file(s) with block size a multiple&
  11. !      of 512 - for example:                        &
  12. !        $ BACKUP files saveset.fil/SAVE_SET/BLOCK_SIZE=2048    &
  13. !        $ R KERMITFIX                        &
  14. !    o answer questions - output file will be fixed 512 byte records    &
  15. !    o transfer file using KERMIT - receiving VAX KERMIT should be     &
  16. !      SET FILE TYPE FIXED                        &
  17. !    o run kermitfix again - answer questions - output file is now    &
  18. !      same recordsize as original backup save_set - backup can     &
  19. !      now restore the files                        &
  20. !
  21. 100    on error goto 25000
  22.     Print "KERMITFIX - 19-Feb-1985"
  23. 110    input "Backup file block_size <2048>"; backsize%
  24.     backsize% = 2048% if backsize% = 0%    ! supply default
  25.     if (backsize%/512%)*512% <> backsize% 
  26.     then
  27.       print "Backup file block_size must be a multiple of 512" 
  28.       goto 110
  29.     end if
  30. 120    input "File to convert"; infile$
  31.     insize% = 512%            ! assume input is Kermit-format file
  32. 130    open infile$ for input as file #1%    &
  33.         ,sequential fixed        &
  34.         ,recordtype none        &
  35.         ,recordsize insize%
  36.     print "Converting from Kermit to Backup format"
  37.     outsize% = backsize%
  38.     goto 150
  39. 140    insize% = backsize%        ! input is BACKUP format
  40.     outsize% = 512%         ! output is Kermit format
  41.     open infile$ for input as file #1%    &
  42.         ,sequential fixed        &
  43.         ,recordtype none        &
  44.         ,recordsize insize%
  45.     print "Converting from Backup to Kermit format"
  46. 150    print "Output file name <"; infile$;
  47.     input ">"; outfile$
  48.     outfile$ = infile$ if outfile$ = ""    ! supply default
  49. 160    open outfile$ for output as file #2%    &
  50.         ,sequential fixed        &
  51.         ,recordtype none        &
  52.         ,recordsize outsize%
  53.  
  54. 170    if insize% <> 512% then 220
  55. 180!      convert from Kermit format to Backup format
  56.       field #1%, 512% as in$    ! point to input buffer
  57. 190      outcount% = 0%        ! nothing yet in output buffer
  58.       for c% = 0% to outsize%/512%-1%
  59. 200        get #1%
  60.         field #2%, c%*512% as out$, 512% as out$! point to output buffer
  61.         lset out$ = in$        ! put data into output buffer
  62.         outcount% = outcount% + 512%! count characters in output buffer
  63.       next c%            ! until it's full
  64.       put #2%, count outcount%    ! write output buffer
  65.       goto 190
  66. 210      if outcount% > 0% then put #2%, count outcount%
  67.     goto 240
  68. 220!      convert from Backup format to Kermit format
  69.       field #2%, 512% as out$    ! point to output buffer
  70. 230      get #1% \ incount% = recount    ! get record
  71.       for c%=0% to incount%/512%-1%
  72.         field #1%, c%*512% as in$, 512% as in$    ! break input buffer
  73.         lset out$ = in$        ! move data to output buffer
  74.         put #2%            ! write to file
  75.       next c%
  76.       goto 230
  77. 240    close 1%,2% \ goto 32767    &
  78.  
  79. 25000!    error handling routines
  80.     if err <> 11% then 25100
  81. 25010    if erl = 110% then resume 32767
  82. 25020    if erl = 120% then resume 32767
  83. 25030    if erl = 150% then resume 32767
  84. 25040    if erl = 200% then resume 210
  85. 25050    if erl = 230% then resume 240
  86. 25100    if err = 148% and erl = 130% then resume 140
  87. 25110    on error goto 0
  88.  
  89. 32767    end
  90.