home *** CD-ROM | disk | FTP | other *** search
- 10 ' *********************************************************************
- 20 ' * PC-File Sample program. *
- 30 ' *********************************************************************
- 40 ' *
- 50 ' * This program reads a sample database, in sequence by the most
- 60 ' * recent sort (in sequence by Index). For each record read, a line
- 70 ' * is printed on the printer.
- 80 ' * The name of the database is "SAMPLE".
- 90 ' *
- 100 '* The sample file was defined as follows:
- 110 '* NAM 20
- 120 '* ADDRESS 25
- 130 '* CITY 12
- 140 '* STATE 2
- 150 '* ZIP 5
- 160 '* ---
- 170 '* 64 (total length of data fields)
- 180 '*
- 190 '* The length of an index record is therefore:
- 200 '* 2 * (number of fields) + 4, or
- 210 '* 2 * 5 + 4 = 14
- 220 '*
- 230 '* The length of a data record is:
- 240 '* Length of data fields + 1, or
- 250 '* 64 + 1 = 65
- 260 '
- 270 '* NOTE: if record length is longer than 128, then you must start BASIC
- 280 '* with the /S:512 option. See page 2-4 in your BASIC manual.
- 285 '
- 286 END ' This is here because some people INSIST on trying to RUN this!
- 287 ' You'll want to put it elsewhere in a production program.
- 290 '....................................................................
- 300 ' DATA INITIALIZATION
- 310 '
- 320 INX.LEN = 14
- 330 DTA.LEN = 65
- 340 '....................................................................
- 350 ' OPEN FILES FOR PROCESSING
- 360 '
- 370 OPEN "SAMPLE.INX" AS #1 LEN=INX.LEN
- 380 FIELD #1, 10 AS X.INX$, 4 AS POINTER.INX$
- 390 OPEN "SAMPLE.DTA" AS #2 LEN=DTA.LEN
- 400 FIELD #2, 20 AS NAM$, 25 AS ADDRESS$, 12 AS CITY$, 2 AS STATE$, 5 AS ZIP$
- 410 '...................................................................
- 420 ' READ AND PROCESS THE DATA
- 430 '
- 440 GET #1 ' GET NXT SEQUENTIAL INX RCD
- 450 IF LEFT$(X.INX$,1) = "/" THEN 440 ' DELETED RECORD
- 460 IF LEFT$(X.INX$,1) = "\" THEN 510 ' END OF FILE
- 470 POINTER = VAL(POINTER.INX$) ' GET POINTER INTO DATA FILE
- 480 GET #2,POINTER ' RANDOM RETRIEVE DTA RECORD
- 490 LPRINT NAM$;" ";ADDRESS$;" ";CITY$;" ";STATE$;" ";ZIP$
- 500 GOTO 440
- 510 '...................................................................
- 520 ' PROCESSING IS COMPLETED. SHUTDOWN.
- 530 '
- 540 CLOSE
- 550 END