[next] [previous] [contents]

  19.1.7 Controlling Tape Output Format
  Magnetic tape physical records range from 18 to 8192 bytes.
  With RMS tapes, you can optionally specify this size in the
  BLOCKSIZE clause as a positive integer indicating the num-
  ber of records in each block. BASIC then calculates the actual
  size in bytes. Thus, a fixed-length file on tape with 126 byte
  records can have a block size from 1 to 64, inclusive. The
  default is 126 bytes (one record per block).

  In the following example of an OPEN statement, the
  RECORDSIZE clause defines the size of the records in the file
  as 90 bytes, and BLOCKSIZE defines the size of a block as
  12 records (1080 bytes). Thus, your program contains an I/O
  buffer of 1080 bytes. Each physical read or write operation
  moves 1080 bytes of data between the tape and this buffer.
  Every twelfth GET or PUT operation causes a physical read
  or write. The next eleven GET or PUT operations only move
  data into or out of the I/O buffer. Specifying a block size
  larger than the default can reduce overhead by eliminating
  some physical reading and writing to the tape. In addition,
  specifying a large block size conserves space on the tape by
  reducing the number of interrecord gaps (IRGs). In the ex-
  ample, a block size of 12 saves time by accessing the tape only
  after every twelfth record operation.
  OPEN "MT0:[SMITH]TEST.SEQ" FOR OUTPUT AS FILE #12% &
                        ,ORGANIZATION SEQUENTIAL FIXED, RECORDSIZE 90% &
                        ,BLOCKSIZE 12%

  Through RMS, BASIC controls the blocking and deblock-
  ing of records. RMS checks each PUT operation to see if the
  specified record fits in the tape block. If it does not, RMS fills
  the rest of the block with circumflexes (blanks) and starts
  the record in a new block. Records cannot span blocks in
  magnetic tape files.

  When you read blocks of records, your program can issue
  successive GET statements until it locates the fields of the
  record you want. The following program finds and displays
  a record on the terminal. You can invoke the RECOUNT
  function to determine how many bytes were read in the GET
  operation.
  MAP (XXX) NA.ME$ = 5%, address$ = 20%
  OPEN "MTO:FILE.DAT" FOR INPUT AS FILE #4%, &
                  SEQUENTIAL FIXED, MAP XXX, ACCESS READ
  NA.ME$ = ""
  GET #4 UNTIL NA.ME$ - "JONES"
  PRINT NA.ME$; "LIVES AT "; address$
  CLOSE #4
  END