PROGRAM CONVERT_RECORDS ! Fall 1990 DECUS Submissions ! Neither myself nor McDonnell Douglas Missile Systems Company accepts any ! responsibility for the use or reliability of these submissions. They ! may not be sold for profit, but may be distributed freely otherwise. ! written by: ! Charles M. Taylor ! McDonnell Douglas Missile Systems Company ! Mailcode 3064105 ! P. O. Box 516 ! St. Louis, MO 63166-0516 ! This program reads a file that was copied from an ! initialized tape on a TU81 Plus tape drive. This program ! assumes the following commands were used to read the tape. ! ! MOUNT/FOREIGN/BLOCK=2048/RECORD=128 tape-drive: ! COPY tape-drive:*.* * ! ! The 128-byte records will be converted into a variable-length ! file. CHARACTER*40 FILE_IN ! filename CHARACTER*40 FILE_OUT ! filename CHARACTER*17 FILE_IN_PROMPT/'INPUT FILENAME : '/ !prompt CHARACTER*17 FILE_OUT_PROMPT/'OUTPUT FILENAME: '/ !prompt INTEGER*4 FILE_IN_LEN ! filename-length INTEGER*4 FILE_OUT_LEN ! filename-length CHARACTER*128 RECORD /' '/ ! input record CHARACTER*128 NEW_RECORD ! output record INTEGER*4 START_REC ! byte where next record starts CHARACTER*4 REC_COUNT_ASC ! byte count - ASCII INTEGER*4 REC_COUNT_INT ! byte count - integer INTEGER*4 MARK_NEW_REC ! mark position in a new record ! where a partial record ends INTEGER*4 BYTES_REMAINING ! number of bytes that are carried ! over to the next record INTEGER*4 NN ! column number where ASCII ! byte count starts CHARACTER*4 CIRCUMFLEX /'^^^^'/ ! Prompt for the names of input and output files, then open them CALL LIB$GET_INPUT( FILE_IN,FILE_IN_PROMPT,FILE_IN_LEN ) CALL LIB$GET_INPUT( FILE_OUT,FILE_OUT_PROMPT,FILE_OUT_LEN ) OPEN( UNIT=1,FILE=FILE_IN,STATUS='OLD' ) OPEN( UNIT=2,FILE=FILE_OUT,STATUS='NEW' 1 ,CARRIAGECONTROL='LIST' ) ! Start of the loop. Read a record. 100 START_REC = 1 READ( 1,1,END=999 ) RECORD 1 FORMAT( A128 ) 200 CONTINUE IF ( START_REC .LT. 126 ) THEN REC_COUNT_ASC( 1:4 ) = RECORD( START_REC:(START_REC+3) ) ! Special cases must be checked if we are at the end of a 128-byte ! record. The byte count may be separated on two records. ELSE NN = 128-START_REC +1 REC_COUNT_ASC( 1:NN ) = RECORD( START_REC:128 ) IF ( REC_COUNT_ASC( 1:NN ) .EQ. CIRCUMFLEX( 1:NN ) ) GOTO 100 READ( 1,1,END=999 ) RECORD REC_COUNT_ASC( NN+1:4 ) = RECORD( 1:4-NN ) START_REC = -NN +1 END IF IF ( REC_COUNT_ASC .EQ. CIRCUMFLEX ) GOTO 100 ! The record byte count is in ASCII, convert to integer longword CALL OTS$CVT_TI_L ( REC_COUNT_ASC,REC_COUNT_INT,, ) IF ( START_REC+REC_COUNT_INT .GT. 128 ) THEN BYTES_REMAINING = ( START_REC+REC_COUNT_INT -1 ) - 128 MARK_NEW_REC = REC_COUNT_INT - 4 - BYTES_REMAINING NEW_RECORD( 1:MARK_NEW_REC ) = 1 RECORD( START_REC+4:128 ) READ( 1,1,END=999 ) RECORD START_REC = 1 NEW_RECORD( MARK_NEW_REC+1:MARK_NEW_REC+BYTES_REMAINING ) 1 = RECORD( 1:BYTES_REMAINING ) START_REC = BYTES_REMAINING +1 ELSE NEW_RECORD( 1:REC_COUNT_INT-4 ) = 1 RECORD( START_REC+4:REC_COUNT_INT + START_REC -1) START_REC = START_REC + REC_COUNT_INT END IF WRITE( 2,2 ) NEW_RECORD( 1:REC_COUNT_INT-4 ) NEW_RECORD = ' ' 2 FORMAT(A) GOTO 200 999 STOP 'End of File' END