home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / DSKCACHE / CACHE_.ZIP / RANDOM.BAS < prev    next >
Encoding:
BASIC Source File  |  1987-02-04  |  4.0 KB  |  103 lines

  1. 100 REM  Portable Computer Support Group, Inc.
  2. 110 REM  Disk buffer demonstration for LIGHTNING Version 3 or 4
  3. 120 REM
  4. 130 REM  This program reads a 40K file consisting of 320 x 128-byte records.
  5. 140 REM  The code that creates this file is at the end of this listing.
  6. 150 REM
  7. 160 DEFINT A-Z
  8. 170 KEY 1,""
  9. 180 KEY 2,""
  10. 190 KEY 10,""
  11. 200 KEY OFF
  12. 205 CLS
  13. 210 DEF SEG=0                                  ' point at interrupt vectors
  14. 220 DEF SEG=PEEK(&H13*4+3)*256+PEEK(&H13*4+2)  ' get base of LIGHTNING
  15. 230 IF PEEK(260)-220 OR PEEK(261)-220 THEN LOCATE 20,24: PRINT "LIGHTNING not installed": NOL=1
  16. 240 STATUS$="OFF": GOSUB 830                   ' turn caching off
  17. 250 OPEN "d_file1.320" AS #1 LEN=128
  18. 260 GOSUB 560                                  ' initialise things
  19. 280 GOSUB 650                                  ' display headings
  20. 290 FIELD #1, 4 AS RECNUM$
  21. 300 WHILE NOT DONE
  22. 310   I=I+1
  23. 320   RECNUM=RND(1)*319+1
  24. 330   GET #1,RECNUM
  25. 340   PRINT USING "####";CVI(RECNUM$);
  26. 350   IF CVI(RECNUM$)<>RECNUM THEN PRINT " error! ";
  27. 360   X=POS(0): Y=CSRLIN
  28. 370   IF CSRLIN>23 THEN CLS: GOSUB 650
  29. 380   K$=INKEY$: IF K$="" GOTO 310
  30. 390   IF K$=CHR$(0)+CHR$(68) THEN GOSUB 560: GOSUB 650: GOTO 450 ' F10=reset
  31. 400   IF K$=CHR$(0)+CHR$(59) THEN STATUS=1:             GOTO 430 ' F1 = on
  32. 410   IF K$=CHR$(0)+CHR$(60) THEN STATUS=0:             GOTO 430 ' F2 = off
  33. 420   STATUS=0: DONE=-1                                          ' else= exit
  34. 430   GOSUB 830                                 ' turn caching on/off
  35. 440   LOCATE 1,63: PRINT STATUS$
  36. 450   LOCATE Y,X
  37. 460 WEND
  38. 470 CLOSE
  39. 480 PRINT
  40. 490 KEY 1,"LIST "
  41. 500 KEY 2,"RUN"+CHR$(13)
  42. 510 KEY 10,"SCREEN 0,0,0"
  43. 520 SYSTEM
  44. 530 REM
  45. 540 REM initialisation
  46. 550 REM
  47. 560 STTIME$=TIME$
  48. 570 STHRS=VAL(MID$(TIME$,1,2))
  49. 580 STMIN=VAL(MID$(TIME$,4,2))
  50. 590 STSEC=VAL(MID$(TIME$,7,2))
  51. 600 I=0
  52. 610 RETURN
  53. 620 REM
  54. 630 REM display headings
  55. 640 REM
  56. 650 LOCATE 1,1
  57. 660 PRHRS=VAL(MID$(TIME$,1,2))
  58. 670 PRMIN=VAL(MID$(TIME$,4,2))
  59. 680 PRSEC=VAL(MID$(TIME$,7,2))
  60. 690 EL=(PRHRS-STHRS)*3600 + (PRMIN-STMIN)*60 + (PRSEC-STSEC)
  61. 700 PRINT "Start   time is ";STTIME$;     TAB(50);"LIGHTNING is ";STATUS$
  62. 710 PRINT "Present time is ";TIME$;       TAB(50);"F1 turns LIGHTNING on"
  63. 720 PRINT "Elapsed time is";EL;"secs";    TAB(50);"F2 turns LIGHTNING off"
  64. 730 PRINT "Number of records read is";I;
  65. 740 IF I<>0 AND EL<>0 THEN PRINT "=";CINT(I/EL);"per sec.";
  66. 750 PRINT                                 TAB(50);"F10 resets statistics"
  67. 760 PRINT                                 TAB(50);"Anything else exits"
  68. 770 PRINT "Reading record numbers:"
  69. 780 LOCATE 8,1
  70. 790 RETURN
  71. 800 REM
  72. 810 REM turn caching on/off - param STATUS = 0/1
  73. 820 REM
  74. 830 IF NOL THEN RETURN                    ' no action if LIGHTNING not installed
  75. 832   IF STATUS THEN STATUS$="ON " ELSE STATUS$="OFF"
  76. 834   FOR J=&H106 TO &H111
  77. 840     POKE J,STATUS OR (PEEK(J) AND -2) 'remove old status, insert new status
  78. 850   NEXT
  79. 860 RETURN
  80. 870 REM
  81. 880 REM-------------------------------------------------------------+
  82. 890 REM                                                             |
  83. 900 REM This is the code that created the 40K data file used above. |
  84. 910 REM                                                             |
  85. 920 REM The first 2 bytes of each record contain the record number. |
  86. 930 REM When the record is read,  this number is printed on screen, |
  87. 940 REM and also compared against the record number to confirm that |
  88. 950 REM the correct record number has been read.                    |
  89. 960 REM                                                             |
  90. 970 REM The remaining bytes of each record contain a decription of  |
  91. 980 REM the record number just for fun.                             |
  92. 990 REM-------------------------------------------------------------+
  93. 1000 REM
  94. 1010 OPEN "d_file1.320" AS #1 LEN=128
  95. 1020 FIELD #1, 2 AS RECNUM$, 126 AS RECASC$
  96. 1030 FOR I=1 TO 320
  97. 1040   LSET RECNUM$=MKI$(I)
  98. 1050   LSET RECASC$="  This is record #"+STR$(I)+" of 320   "
  99. 1060   PUT #1,I
  100. 1070 NEXT
  101. 1080 CLOSE
  102. 1090 END
  103.