TS BULLETIN #3-92
This is an editor in BASIC that works much like the m/c LDOS editor for entering an LDOS command line. If you were to put in your program, GOSUB 4400 this routine would allow you to enter a BASIC line such as an LDOS command, as necessary to get it in as a disk command after that RAND USR 1 4336 call for LDOS. GOSUB 4545 would then make this call, although you would want your program also to do some checking as to the correctness of the command before turning it over to LDOS, since any error results in the ‘real’ LDOS screen being activated. This shows you roughly how the LDOS screen edit for LDOS command line works as well. Lines 4520 – 4530 use a trick useful to learn for other uses.
4399 REM FOR ZX81/TS1000 ONLY
4400 REM THIS INITIALIZATION IS
NEEDED IN YOUR PROGRAM
SOMEWHERE (LINES 4400 - 4490)
4410 SLOW
4490 LET Y=0
4500 REM START OF ACTUAL EDIT
ROUTINE TO MODIFY REM LINE 4550
4505 IF Y>19 OR Y<0 THEN LET
Y=0
4510 PRINT AT Y,0;"14spacesxxx
xxx";AT Y+1,0;"*";
4511 REM PRINT * PROMPT
4515 LET X$=""
4517 LET A$="21spacesxxxxxxxxx
xxxx"
4518 REM 19SPC, SEE 4650
4520 LET N=5
4525 REM lines next must NOT ch
ange
4530 LET NA=28+PEEK 16425*PEEK
16426
4540 GOTO VAL"4560"
4545 RAND USR VAL"14336"
4550
REM42spacesxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxx(note a lot of sp
aces here)
4555 REM CHANGE N IN LINE 4520
TO 10 AND ALL OTHER OCCURRENCES
OF 5 TO 10 IN THIS ROUTINE TO S
TART WITH FIRST 5 CHARS. IN REM
AT 4550 SET TO FOR EXAMPLE PERM
ANENTLY TO SOMETHING, LIKE LOAD
" AND ALSO MAY WANT TO CHANGE 1
9 IN LINE 4620 TO 18 IF DO THIS
-NA=address for POKE, of first
char . after REM(4550)
4557 RETURN
4558 REM RETURN FOR RAND USR 14
336 CALL see top
4560 LET X=0
4561 REM NOTHING ELSE MUST GO F
ROM 45 30 TO 4550---
4570 LET X$=INKEY$
4571 REM NOTHING=NOT EVEN ONE B
YTE MORE OR LESS
4580 IF X$="" THEN GOTO 4570
4590 LET X=CODE X$
4595 IF X=119 AND N>5 THEN PRIN
T AT Y+1,(N+1-1-5);CHR$(128 PEE
K(NA+N))
4596 REM THAT LINE WILL INVERT
ON BACKSPACE LIKE LDOS-- WHICH
IS A BIT CRUDE, BACKSPACE=RUBUT
OR DELETE ON ZX81/TS1000 KEYBOA
RD, remove -1 AFTER N IF YOU DO
NOT USE A PROMPT LIKE THE * USE
D HERE AT BEGINNING CMD LINE FO
R EXAMPLE, ALTHO OTHER CHANGES
NEEDED IN CODE TO DO THAT ALSO
4600 IF X=119 AND N>5 THEN LET
N=N-1
4601 REM BACKSPACE POSITION IN
LINE
4610 IF X=119 THEN GOTO 4560
4611 REM MAKES NOT ENTRY OR CHA
NGE IN INPUT
4620 IF N>19 OR X>63 OR Y>20 TH
EN GOTO 4698
4621 REM IF X>63 catches ENTER-
N/L
4622 REM IF X>63 IS ALSO A CRUD
E ERROR REJECTOR, Y>20 IS NOT G
OOD FOR BOT.SCRN.
4630 PRINT AT Y+1,(N+1-5);X$
4631 REM REMOVE THE 1 IF REV.,
See 4555,PRMPT
4635 REM THIS IS THE PRINT THAT
PUTS THE CHARACTER KEYED -IN ON
SCRN.,(ECHOS IT)
4640 POKE NA+N,X
4645 REM THIS POKES THE CODE
INTO THE REM STATEMENT ON LINE
4550
4650 LET A$(N TO N)=X$
4655 REM THIS MIGHT BE USED TO
PUT THE COMM AND INTO A STRING
A$ SO THAT IT COULD BE ANALYZED
/PARSED-ERROR CHECKED ELSEWHERE
, SEE ALSO LINE 4517 ABOVE
4660 LET N=N+1
4661 REM MOVES POSITION POINTER
, CMD. STRING/LINE FWD.
4670 GOTO 4560
4697 REM INCREMENTS PRINT LINE
LIKE LDOS SCROLLING
4698 LET Y=Y+2
4699 RETURN
4700 REM THIS ENDS EDIT ROUTINE
CALLED AS SUBROUTINE TO EDIT 1
LINE
This has been typed from a tested program with some elaboration, mainly extra REM statements to clarify its operation principles. Use of a routine like this will help in putting LDOS commands into a running program and as a bonus LISTing it gives the reader a hint as to the steps that the LDOS line editor for LDOS (command line) goes through. The LDOS CLINE editor is in m/c though.
A routine like this could be used to build a utility program for use with LDOS or a BASIC or part-BASIC operating system shell, etc. A few lines added to translate from a completely different command language into LDOS command language , POKEd into the REM statement is another approach to this, so that COPY could be translated into two LDOS commands, LOAD”—name of file, and SAVE”—name of file, emulating CP/M or MS DOS style of command language!
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.