Get system command output: Difference between revisions

Applesoft BASIC
(Get system command output in Yabasic)
(Applesoft BASIC)
Line 123:
</pre>
 
=={{header|Applesoft BASIC}}==
A small machine language program is POKEd into memory starting at address P. The address of the program P is POKEd into the 54 and 55 zero page locations. CALL 1002 connects output to the program. The system command CATALOG is run, and all output is written to memory starting at address A. PR#0 reconnects output back to the screen. Variables are carefully declared before the first string in the array S$(0) is assigned. The most recent address of S$(0) is used to assign pointers and lengths to the array of strings. S$(C) is the last string in the array.
<lang qbasic> 100 HIMEM: 24576
110 LET A = 24576
120 LET P = 768
130 DEF FN P(A) = PEEK (A) + PEEK (A + 1) * 256
140 DEF FN H(A) = INT (A / 256)
150 DEF FN L(A) = A - FN H(A) * 256
160 POKE P + 00,073: REM EOR
170 POKE P + 01,128: REM #$80
180 POKE P + 02,141: REM STA
190 POKE P + 03, FN L(A)
200 POKE P + 04, FN H(A)
210 POKE P + 05,073: REM EOR
220 POKE P + 06,128: REM #$80
230 POKE P + 07,238: REM INC
240 POKE P + 08, FN L(P + 3)
250 POKE P + 09, FN H(P + 3)
260 POKE P + 10,208: REM BNE
270 POKE P + 11,3
280 POKE P + 12,238: REM INC
290 POKE P + 13, FN L(P + 4)
300 POKE P + 14, FN H(P + 4)
310 POKE P + 15,096: REM RTS
320 POKE 54, FN L(P)
330 POKE 55, FN H(P)
340 CALL 1002
350 PRINT CHR$ (4)"CATALOG"
360 PRINT CHR$ (4)"PR#0"
370 LET C = - 1
380 LET I = 0
390 LET S = 0
400 LET E = FN P(P + 3)
410 DIM S$(54)
420 LET S$(0) = ""
430 POKE 236, PEEK (131)
440 POKE 237, PEEK (132)
450 LET S = FN P(236)
460 FOR I = A TO E STEP 255
470 LET C = C + 1
480 POKE S + C * 3,255
490 IF E - I < 255 THEN POKE S + C * 3,E - I
500 POKE S + C * 3 + 1, FN L(I)
510 POKE S + C * 3 + 2, FN H(I)
520 PRINT S$(C);
530 NEXT </lang>
=={{header|Arturo}}==
 
413

edits