There are numerous random access I/O methods. We'll discuss one prominent method used in many BASICs. It orginated in DEC BASIC-PLUS and lives on in QB64pe and FreeBASIC.
The TRS-80 Model I Disk BASIC was much cruder. All records were 256 bytes longer (1 sector). If you wanted to use 40-byte “logical records”, you’ve have to use some tricky math to find which physical record (sector) your logical record fell in, and then “how far into” that sector it actually appeared. So in our example of 40-byte records, record #10 would be in sector 2, starting at character position 144 (assuming we had logic to “split” record #7 *across* sectors 1 & 2). The code to place those 40 bytes of record #10 in R$ might be
The TRS-80 Model I Disk BASIC was much cruder. All records were 256 bytes longer (1 sector). If you wanted to use 40-byte “logical records”, you’ve have to use some tricky math to find which physical record (sector) your logical record fell in, and then “how far into” that sector it actually appeared. So in our example of 40-byte records, record #10 would be in sector 2, starting at character position 144 (assuming we had logic to “split” record #7 *across* sectors 1 & 2). The code to place those 40 bytes of record #10 in R$ might be
100 OPEN “R”, FILE”, 1
…
1000 GET 1, 7
1010 FIELD 1, 143 AS SP$, 40 AS R$