home *** CD-ROM | disk | FTP | other *** search
- 100 REM Portable Computer Support Group, Inc.
- 110 REM Disk buffer demonstration for LIGHTNING Version 3 or 4
- 120 REM
- 130 REM This program reads a 40K file consisting of 320 x 128-byte records.
- 140 REM The code that creates this file is at the end of this listing.
- 150 REM
- 160 DEFINT A-Z
- 170 KEY 1,""
- 180 KEY 2,""
- 190 KEY 10,""
- 200 KEY OFF
- 205 CLS
- 210 DEF SEG=0 ' point at interrupt vectors
- 220 DEF SEG=PEEK(&H13*4+3)*256+PEEK(&H13*4+2) ' get base of LIGHTNING
- 230 IF PEEK(260)-220 OR PEEK(261)-220 THEN LOCATE 20,24: PRINT "LIGHTNING not installed": NOL=1
- 240 STATUS$="OFF": GOSUB 830 ' turn caching off
- 250 OPEN "d_file1.320" AS #1 LEN=128
- 260 GOSUB 560 ' initialise things
- 280 GOSUB 650 ' display headings
- 290 FIELD #1, 4 AS RECNUM$
- 300 WHILE NOT DONE
- 310 I=I+1
- 320 RECNUM=RND(1)*319+1
- 330 GET #1,RECNUM
- 340 PRINT USING "####";CVI(RECNUM$);
- 350 IF CVI(RECNUM$)<>RECNUM THEN PRINT " error! ";
- 360 X=POS(0): Y=CSRLIN
- 370 IF CSRLIN>23 THEN CLS: GOSUB 650
- 380 K$=INKEY$: IF K$="" GOTO 310
- 390 IF K$=CHR$(0)+CHR$(68) THEN GOSUB 560: GOSUB 650: GOTO 450 ' F10=reset
- 400 IF K$=CHR$(0)+CHR$(59) THEN STATUS=1: GOTO 430 ' F1 = on
- 410 IF K$=CHR$(0)+CHR$(60) THEN STATUS=0: GOTO 430 ' F2 = off
- 420 STATUS=0: DONE=-1 ' else= exit
- 430 GOSUB 830 ' turn caching on/off
- 440 LOCATE 1,63: PRINT STATUS$
- 450 LOCATE Y,X
- 460 WEND
- 470 CLOSE
- 480 PRINT
- 490 KEY 1,"LIST "
- 500 KEY 2,"RUN"+CHR$(13)
- 510 KEY 10,"SCREEN 0,0,0"
- 520 SYSTEM
- 530 REM
- 540 REM initialisation
- 550 REM
- 560 STTIME$=TIME$
- 570 STHRS=VAL(MID$(TIME$,1,2))
- 580 STMIN=VAL(MID$(TIME$,4,2))
- 590 STSEC=VAL(MID$(TIME$,7,2))
- 600 I=0
- 610 RETURN
- 620 REM
- 630 REM display headings
- 640 REM
- 650 LOCATE 1,1
- 660 PRHRS=VAL(MID$(TIME$,1,2))
- 670 PRMIN=VAL(MID$(TIME$,4,2))
- 680 PRSEC=VAL(MID$(TIME$,7,2))
- 690 EL=(PRHRS-STHRS)*3600 + (PRMIN-STMIN)*60 + (PRSEC-STSEC)
- 700 PRINT "Start time is ";STTIME$; TAB(50);"LIGHTNING is ";STATUS$
- 710 PRINT "Present time is ";TIME$; TAB(50);"F1 turns LIGHTNING on"
- 720 PRINT "Elapsed time is";EL;"secs"; TAB(50);"F2 turns LIGHTNING off"
- 730 PRINT "Number of records read is";I;
- 740 IF I<>0 AND EL<>0 THEN PRINT "=";CINT(I/EL);"per sec.";
- 750 PRINT TAB(50);"F10 resets statistics"
- 760 PRINT TAB(50);"Anything else exits"
- 770 PRINT "Reading record numbers:"
- 780 LOCATE 8,1
- 790 RETURN
- 800 REM
- 810 REM turn caching on/off - param STATUS = 0/1
- 820 REM
- 830 IF NOL THEN RETURN ' no action if LIGHTNING not installed
- 832 IF STATUS THEN STATUS$="ON " ELSE STATUS$="OFF"
- 834 FOR J=&H106 TO &H111
- 840 POKE J,STATUS OR (PEEK(J) AND -2) 'remove old status, insert new status
- 850 NEXT
- 860 RETURN
- 870 REM
- 880 REM-------------------------------------------------------------+
- 890 REM |
- 900 REM This is the code that created the 40K data file used above. |
- 910 REM |
- 920 REM The first 2 bytes of each record contain the record number. |
- 930 REM When the record is read, this number is printed on screen, |
- 940 REM and also compared against the record number to confirm that |
- 950 REM the correct record number has been read. |
- 960 REM |
- 970 REM The remaining bytes of each record contain a decription of |
- 980 REM the record number just for fun. |
- 990 REM-------------------------------------------------------------+
- 1000 REM
- 1010 OPEN "d_file1.320" AS #1 LEN=128
- 1020 FIELD #1, 2 AS RECNUM$, 126 AS RECASC$
- 1030 FOR I=1 TO 320
- 1040 LSET RECNUM$=MKI$(I)
- 1050 LSET RECASC$=" This is record #"+STR$(I)+" of 320 "
- 1060 PUT #1,I
- 1070 NEXT
- 1080 CLOSE
- 1090 END