! MExample Program 11-4

! Demonstration of using a record file.

! color the output display

! do trace,step(title$,recnum)

 

OPEN #1: name "NAME.REC", create newold, org record

ERASE #1 ! if the file already exists

SET #1: RECSIZE 30 ! record size in bytes

 

! Add information to the file.

RESET #1: begin ! just a precaution

FOR I = 1 to 5

READ Title$

WRITE #1: Title$

NEXT I

SET COLOR "red"

PRINT "A record file of ledger titles has been created."

PRINT

 

! Specify a record number.

SET COLOR "blue"

PRINT "Enter zero to stop."

SET COLOR "green"

INPUT prompt "Display which record? ": RecNum

DO until RecNum = 0

IF RecNum > 0 AND RecNum <= 5 then

SET #1: RECORD RecNum

READ #1: Title$

PRINT "Title: "; Title$

ELSE

PRINT "There are only 5 records."

END IF

PRINT

INPUT prompt "Display which record? ": RecNum

LOOP

 

DATA Labor, Equipment, Supplies, Travel, Utilities

END