No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

95 líneas
2.9KB

  1. 1 REM =====================================================
  2. 2 REM DISK-ACCESS.BAS — C64 1541 Disk I/O Examples
  3. 3 REM Demonstrates: sequential files, relative files,
  4. 4 REM error channel, directory reading
  5. 5 REM =====================================================
  6. 100 REM =====================
  7. 101 REM SECTION 1: ERROR CHANNEL SUBROUTINE
  8. 102 REM =====================
  9. 103 REM Open the command channel once and keep it open: closing 15 makes the
  10. 104 REM drive close every other file. GOSUB 9000 sets EN, EM$, ET, ES.
  11. 105 OPEN 15,8,15 : GOTO 200
  12. 9000 REM --- READ ERROR CHANNEL ---
  13. 9020 INPUT#15, EN, EM$, ET, ES
  14. 9040 IF EN > 1 THEN PRINT "DISK ERROR" EN EM$ "T"ET "S"ES
  15. 9050 RETURN
  16. 200 REM =====================
  17. 201 REM SECTION 2: WRITE SEQUENTIAL FILE
  18. 202 REM =====================
  19. 210 PRINT "WRITING SEQUENTIAL FILE..."
  20. 220 OPEN 1, 8, 2, "MYDATA,S,W"
  21. 230 GOSUB 9000 : IF EN > 1 THEN CLOSE 1 : GOTO 299
  22. 240 PRINT#1, "RECORD 1"
  23. 250 PRINT#1, "RECORD 2"
  24. 260 PRINT#1, 12345
  25. 270 PRINT#1, "LAST RECORD"
  26. 280 CLOSE 1
  27. 290 GOSUB 9000
  28. 299 PRINT "WRITE DONE."
  29. 300 REM =====================
  30. 301 REM SECTION 3: READ SEQUENTIAL FILE
  31. 302 REM =====================
  32. 310 PRINT "READING SEQUENTIAL FILE..."
  33. 320 OPEN 1, 8, 2, "MYDATA,S,R"
  34. 330 GOSUB 9000 : IF EN > 1 THEN CLOSE 1 : GOTO 399
  35. 340 INPUT#1, LINE$ : S=ST : REM read first; ST is valid right after the read
  36. 350 PRINT "READ: "; LINE$
  37. 360 IF S = 0 THEN GOTO 340 : REM 64 = end of file, other values = error
  38. 380 CLOSE 1
  39. 390 GOSUB 9000
  40. 399 PRINT "READ DONE."
  41. 400 REM =====================
  42. 401 REM SECTION 4: READ DIRECTORY
  43. 402 REM =====================
  44. 410 PRINT "DIRECTORY:"
  45. 420 REM LOAD "$",8 in a program would replace the program; read "$" as a file:
  46. 450 OPEN 1, 8, 0, "$"
  47. 460 GET#1, A$, B$ : REM load address (2 bytes)
  48. 470 GET#1, A$, B$ : IF ST <> 0 THEN GOTO 530 : REM line link; 0,0 = end
  49. 480 GET#1, A$, B$ : N = ASC(A$+CHR$(0)) + 256*ASC(B$+CHR$(0)) : REM blocks
  50. 490 L$ = ""
  51. 500 GET#1, C$ : IF C$ <> "" THEN L$ = L$ + C$ : GOTO 500
  52. 510 PRINT N; L$ : GOTO 470
  53. 530 CLOSE 1
  54. 600 REM =====================
  55. 601 REM SECTION 5: SEND DOS COMMANDS
  56. 602 REM =====================
  57. 610 REM Scratch a file
  58. 620 PRINT "SCRATCHING OLD BACKUP..."
  59. 630 PRINT#15, "S0:BACKUP"
  60. 650 GOSUB 9000
  61. 660 REM Rename a file
  62. 670 PRINT "RENAMING FILE..."
  63. 680 PRINT#15, "R0:NEWNAME=MYDATA"
  64. 700 GOSUB 9000
  65. 710 REM Validate disk
  66. 720 PRINT "VALIDATING DISK..."
  67. 730 PRINT#15, "V0:"
  68. 750 GOSUB 9000
  69. 800 REM =====================
  70. 801 REM SECTION 6: LOAD ML PROGRAM
  71. 802 REM =====================
  72. 810 REM Load ML at its original address (SA=1), e.g.:
  73. 820 REM LOAD "MLPROG",8,1 (in a program, LOAD restarts the program after loading)
  74. 830 CLOSE 15 : PRINT "DONE."
  75. 835 POKE 55295,0 : REM $D7FF: tells `c64 test` the run finished (no effect on hardware)
  76. 840 END
  77. 900 REM =====================
  78. 901 REM SUBROUTINE: WAIT FOR KEY
  79. 902 REM =====================
  80. 910 PRINT "PRESS ANY KEY..."
  81. 920 GET K$ : IF K$="" THEN GOTO 920
  82. 930 RETURN

Powered by TurnKey Linux.