Sample Programs
Three programs are included in this section. The first illustrates some of the techniques
that can be used for file management, showing how to open a file, write records
randomly to it, and read records randomly from it. The second program shows how to
save the contents of the screen on a file and put it back on the screen later. This is
useful if you have created a graphics screen and want to be able to store and retrieve it.
The third program shows how to read the catalog from a diskette using TI BASIC.
GENERAL PROGRAM - The following program illustrates general file handling
techniques for a random-access file.
The first section, lines 100 through 120, gives the entry instruction.
1 00 CALL CLEAR
1 1 0 OPEN #2 :"oSK1 .GENFILE",RELATIVE 50,INTERNAL
1 20 PRINT "ENTER
'XXX'
TO LEAVE ENTRY"::
The next section, lines 130 through 2 10, allows entry of up to 50 records, numbered 1
through 50. Line 160 checks to see if the last record has been entered. If 50 records
have been entered, line 2 l O informs the user that the file is full.
1 30 REM ENTRY SECTION
1 40 TOTAL
=
0
1 50 INPUT " RECORD " &STR$(TOTAL
+
1 )&" " :BUFFER$
1 60 IF BUFFER$
=
"XXX" THEN 220
1 70 PRINT #2,REC TOTAL
+
1
:BUFFER$
1 BO TOTAL
=
TOTAL
+
1
1 90 IF TOTAL < 50 THEN 1 50
200 REM PRINT FULL MESSAGE
21 0 PRINT "FILE FULL"
The next section, lines 220 through 320, allows the user to choose what to do.
38
220 REM CONTROL SECTION
230 PRINT
::"1
=
PRINT FILE"
240 PRINT "2
=
PRINT A RECORD"
250 PRINT "3
=
CHANGE A RECORD"
260 PRINT "4
=
ADD A RECORD"
270 PRINT "5
=
LEAVE THE PROGRAM " : : :
280 INPUT "ENTER YOUR CHOICE? ":X
290 PRINT
300 IF X< 1 THEN 220
3 1 0 IF X > 5 THEN 220
320 ON X GOTO 1 000, 2000,3000.4000,5000
Summary of Contents for PHP1240
Page 1: ......