Herunterladen Inhalt Inhalt Diese Seite drucken

Sample Programs - Texas Instruments Php 1240 Bedienungsanleitung

Diskehensystem
Inhaltsverzeichnis
Verfügbare Sprachen
  • DE

Verfügbare Sprachen

~
TEXAS INSTRUMENTS
Records 1 through 127 contain information about the correspon-
ding fil es in the index. The string item is the file name, and the nu-
meric items are as follows:
e
the file type (a negative value if the file is protected)
1 = DISPLAV/FlXED data file
2 = DISPLAVIVARIABLE data file
3 = INTERNAUFIXED data file
4 = INTERNALIVARIABLE data file
5 = BASIC program or other "memory image" data
e
The total number of sectors allocated for the file
e
The total number of by1es per record
A type-5 file always has a zero (0) as the number of by1es per re-
cord, since this measurement does not re late to memory image da-
ta.
A sample program listed at the end ofthis section illustrates howto
display a diskette catalogue.
SAMPLE PROGRAMS
Three programs are included in this section. The first illustrates so-
me of the techniques that can be used for file management, sho-
wing how to open a file, write record randomly to it, and read re-
cords 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 la-
ter. This is useful if you h ave created a graphics screen and want to
be able to stare and retrieve it. The third program shows how to
read the catalogue from a diskette using TI BASIC.
GENERAL PROGRAM- The following program shows generai file
handling techniques for a random-access file.
The first section, lines 100 through 130, gives the entry instruc-
tions.
1 00 CALL CLEAR
110 OPEN
*
10:"DSK1.GENFILE",
RELATIVE 50,1NTERNAL
120 PRINT "ENTER'XXX'
TO LEA VE ENTRV."
130 PRINT
The next section, lines 140 through 220, allows entry of up to 50 re-
cord, numbered O through 49.
Li
ne 180 checks to see if the lastre-
cords has been entered. lf 50 records have been entered, li ne 220
informs the user that the file is full.
140 REM ENTRV
150 FOR RECORD1 = O TO 49
160 PRINT "RECORD"; RECORD1;
170 INPUT X$
180 IF X$ = "XXX" THEN 230
190 PRINT
1 O, REC RECORD1 :X$
200 NEXT RECORD1
210 REM FULL
220 PRINT "FILE FULL"
The next section, lines 230 through370, allows the program userto
choose what he would like to do.
230 REM CONTROL SECTION
240 PRINT
250 PRINT "ENTER 'S' TO PRINT FILE"
260 PRINT "SEQUENTIALLV."
270 PRINT "ENTER 'C' TO CHANGE OR ADO"
280 PRINT "A RECORD."
290 PRINT "ENTER 'R' TO PRINT A RECORD."
300 PRINT "ENTER 'L' TO LEAVE THE"
310 PRINT "PROGRAM."
320 INPUT "VOUR CHOICE: ":V$
14
330 PRINT
340 IF V$ = "S" THEN 440
350 IF V$ = "C" THEN 530
360 IF V$ = "L" THEN 630
370 IF V$ < > "R" THEN 230
<ffi)
PHP 1240
The next section, lines 380 through 430, prints a specific record.
Une 400 checks to see that the record chosen exists.
380 REM PRINT A RECORD
390 INPUT "WHICH RECORD? ":RECORD2
400 IF RECORD2>RECORD1 - 1 THEN 61 O
41 O INPUT
*
1 O,REC RECORD2:X$
420 PRINT "RECORD";RECORD2;"1S ";X$
430 GOTO 230
The next section, lines 440 through 520, prints the enti re file in se-
quential arder.
440 REM SEQUENTIAL
450 PRINT "THE FOLLOWING ARE THE"
460 PRINT "RECORDS:"
4 70 RESTORE
*
1 O
480 FOR RECORD2 =O TO RECORD1 - 1
490 INPUT
*
1 O:X$
500 PRINT RECORD2;X$
510 NEXT RECORD2
520 GOTO 230
The next section, lines 530 through 620, alows a record to be
changed or added.
Li
ne 550 checks to see that the li neto be chan-
ged or added is not beyond the end of the current file.
530 REM CHANGE A RECORD
540 INPUT "WHICH RECORD? ":RECORD2
550 IF RECORD2>RECORD1 THEN 61 O
560 INPUT "NEW VALUE? ":X$
570 PRINT
*
1 O,REC RECORD2:X$
580 IF RECORD2<RECORD 1 THEN 230
590 RECORD1 = RECORD2
+
1
600 GOTO 230
610 PRINT "RECORD IS BEVONO THE END OF
THE FILE."
620 GOTO 230
The last section, li ne 630, closes the file at the end of the program.
630 CLOSE
*
1 O
SA VE ANO RESTORE A SCREEN
-Li
n es 1 00 through 21 O of the fol-
lowing program can be used as a subroutine in other programs
when you want to save something you've created on the screen.
(Be su re that you change the file name each ti me you use the pro-
gram so that you don't write aver a file that you have previously sa-
ved.) This program only saves and restores the characters that are
on the screen.
lnformation about redefined characters and colours is not saved.
100 REM SAVE A SCREEN
110 REM ADO AT END OF THE PROGRAM THAT
PRODUCES THE SCREEN
120 REM
130 REM CHOOSE A UNIQUE FILENAME
140 OPEN
*
20:"device.file-name",INTERNAL
150 FOR ROW = 1 TO 24
160 FOR COLUMN = 1 TO 32
170 CALL GCHAR[ROW,COLUMN,X]
180 PRINT
*
20:X
190 NEXT COLUMN
200 NEST ROW
210 CLOSE*20
Inhaltsverzeichnis
loading

Inhaltsverzeichnis