Detailed information about CBM Relative (REL) Files 1. Using Relative files in BASIC 2. How Relative files are stored 3. How Relative files are created 1. Using Relative Files in any C= BASIC 2.0 - 10.0: To open for read/write: open1,8,15:open2,8,sa,"filename,l,"+chr$(record length) - sa = secondary address To position to record: print#1,"p" chr$(96+sa)chr$(rec lb)chr$(rec hb)chr$(rec offset) - sa = secondary address from above - rec lb = low byte of the record to position to - rec hb = high byte of the record to position to - rec offset = offset inside the record to start (usually 1) To read/write, use input#, get#, print#, etc. 2. How Relative Files are Represented On Disk: Directory entry: Offset Purpose 0 $84 (file type byte = REL) 1,2 Track & Sector to beginning of all records 3-18 Filename (padded with $a0) 19-20 (90x0, 1581, 8250 only) Track & Sector to Super Side Sector 19-20 (all except above) Track & Sector to Normal Side Sector 21 Record Length (1-254) Super Side Sector 0,1 Track and Sector of first Normal Side Sector 2,3 Same as 0,1 for second Normal Side Sector ... .. repeats to end of sector (so, 127 total) Normal Side Sector 0,1 Track & Sector to next Normal Side Sector (up to 6 total) 2 Contains 0-5 for Which Side Sector this one is 3 Record Length 4,5 Track & Sector to First Side Sector 6,7 Track & Sector to Second Side Sector 8,9 Track & Sector to Third Side Sector 10,11 Track & Sector to Fourth Side Sector 12,13 Track & Sector to Fifth Side Sector 14,15 Track & Sector to Sixth Side Sector 16,17 Track & Sector for an sector of record data ... ... repeats to end of sector (so, 120 sectors total) * Which sector of record data, and the byte position within the sector for each record is calculated by the drive, and then actual T&S looked up in the side sector index 3. How Relative Files are Created When a REL file is created, enough of the Super and Normal side sectors are created to allocate one sector of data, just like when a SEQ file is created for writing. The first data sector is then filled with 0s and $ff is written to the first byte of where each of the first few records would be written in that first sector. The size of this sector is set to the end of those minimal number of records. The size of the first normal side sector is set to $11, and the first data sector is written at offset $10 and $11.