Using the pointer
The next step is to point to the particular byte in the file that you
want to read or write to. The pointer keyword is PTR#.
EXAMPLE
PTR#X=1000
This means: in the file with channel X, point to byte number
1000. The byte number will be increased by 1 each time a byte is
read or written. When a file is opened, the pointer points to byte
0.
Reading and writing
Now you can read or write to the contents of the byte you have
pointed to. The keywords are BGET# (to read a byte) and
BPUT# (to write a byte).
EXAMPLES
NEXTLETTER%=BGET#X
This means: into the variable NEXTLETTER% put the contents
of the byte currently pointed to in the file with channel X.
BPUT#X,32
This means: into the byte currently pointed to in the file with
channel X, put the number 32.
When you are writing to a file, you can increase its size by
pointing beyond the current last byte. For example, if you
OPENUP a file 20 bytes long and then point to byte 100, using
PTR#, the file will be extended to 100 bytes. The extra bytes
inserted will be zeros.
41