Buffer-Pointer - Commodore 1541 User Manual

Hide thumbs Also See for 1541:
Table of Contents

Advertisement

BUFFER-POINTER
The buffer pointer keeps track of where the lasi piece of data was written. It also
is the pointer for where the nex* piece of data is to be read. By changing the buffer
pointer's location within the buffer, you can get random access to the individual bytes
within a block. This way, you can subdivide each block into records.
For example, let's lake a hypothetical mailing list. The information such as name,
address, etc., will take up a total of 64 characters maximum. We could divide each
block of the random access file into 4 separate records, and by knowing the track, sec
tor, and record numbers, we can access that individual record.
FORMAT FOR BUFFER-POINTER COMMAND:
PRINTtffileS, "BUFFER-POINTER:" channel; location
or abbreviated as
PRlNTtffilefl, "B-P:" channel; location
EXAMPLE OF SETTING POINTER TO 64TH CHARACTER OF BUFFER:
PRINTS 15, "B-P:" 5; 64
Here are versions of ihe random access writing and reading programs shown
above, modified to work with records within blocks:
SAMPLE PROGRAM WRITING
10 RANDOM-ACCESS BLOCKS WITH 4
RECORDS EACH:
10
OPEN15.S.15
20
OPEN5,8,5,"#"
30
OPEN4,8>4,"@0:KEYSlSlW1t
^^-^-^-^
40
AS-"RECORD CONTENTS//"
/ set POSITIONS
50 FORR=1T010
s\ TO I, 65r 129, 1W }
60
FORL=tTO4
70
PR[NT#151"B-P:"S;(L-l)*64-f-
80
PRENT#5,A$
90
NEXT L
100 T=L:B=1
110 PRINTS! 5
120 lNPUTfll5,A,l
130 IF A-65THEN T=C:B=D:GOT(
140 PRINTS! 5,"B-W:"5;O;T;B
150 PRLNT#4,TC7'B
160 NEXTR
170 CLOSE4:CLOSE5:CLOSE15
33
FIND
AVAILABLE
TRACK &
BLOCK

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents