The proof-of-concept Tiny BASIC text editor that the people’s permacomputer project sponsors has hit another milestone.
The text editor has added a primitive edit mode.
Edit mode allows a simple search and replace functionality. Please be advised that the program will only replace the first match it finds, requiring the user to rather laboriously repeat typing in the fields.
Ctrl-D (see code, ASCII code number 4) is the keyboard sequence that the user must input in order to complete an edit field. This is somewhat unconventional, but it allows a user to search strings that include newlines.
The code, however, is a global search of the whole buffer, and is a departure from EDITYPE, which required users to step through the buffer one line at a time.
Video
Current Code
Please note that all indentation is for cosmetic purposes only. Many of these lines, if copied and pasted verbatim from this presentation of the code, will be truncated by default Stefan’s BASIC settings.
Apple 1 compatibility is primarily turned on to enable string array functionality.
1 REM PEOPLE'S PERMACOMPUTER EDITOR.
2 REM INSPIRED BY VIC EDITYPE (1983).
3 REM
4 REM DESIGNED FOR THE ARDUINO MEGA 2560.
5 REM WRITTEN IN STEFAN'S BASIC.
6 REM
7 REM PUBLIC DOMAIN DEDICATION.
8 REM
9 REM
10 SET 22,"Apple1"
20 DIM T$(48,24)
30 FOR I=1 TO 24:T$()(I)="":NEXT I
40 DIM SCRATCH$(48)
41 DIM SEARCH$(80)
42 DIM REPLACE$(80)
43 DIM C6$(80)
50 NL=1
60 BKSP=8
70 CR=13
80 LF=10
499 REM FALL INTO HERE
500 REM MENU
510 PRINT: PRINT "N=NEW E=EDIT P=PRINT S=SAVE Q=QUIT"
520 INPUT ">";M$
530 IF M$="N" GOTO 1000
540 IF M$="E" GOTO 3000
550 IF M$="P" GOTO 4000
555 IF M$="S" GOTO 5000
560 IF M$="Q" GOTO 9000
570 GOTO 500
1000 REM COMPOSE MODE
1001 INPUT "TYPE FILE NAME";V$
1002 GOSUB 9000: REM CLEAR SCREEN
1003 PRINT "COMPOSE MODE"
1005 IF NL>24PRINT "LINE LIMIT": GOTO 500
1010 PRINT ">";T$()(NL);
1020 GET C$
1030 IF C$="" THEN GOTO 1020
1040 IF C$="@" THEN GOTO 500
1050 IF C$=CHR$(BKSP) AND LEN(T$()(NL))=0 THEN GOTO 1020
1060 IF C$=CHR$(BKSP) THEN GOTO 1600
1070 IF C$=CHR$(CR) OR C$=CHR$(LF) THEN GOTO 1500
1080 IF ASC(C$)<32 GOTO 1020
1090 PUT C$
1100 T$()(NL)=T$()(NL)+C$
1120 C$=""
1130 IF LEN(T$()(NL))<48 THEN 1020
1199 REM FALL INTO HERE
1200 REM WORD WRAP (IF LINE HITS 48)
1210 S=LEN(T$()(NL))
1220 IF RIGHT$(T$()(NL),1)=" " THEN GOTO 1250
1230 SCRATCH$=T$()(NL+1)
1232 T$()(NL+1)=RIGHT$(T$()(NL),1)+SCRATCH$
1240 T$()(NL)=LEFT$(T$()(NL),S-1)
1245 S=S-1:GOTO 1220
1250 REM MEMORY CHECKS
1260 IF T$()(NL)="" THEN T$()(NL)=" "
1270 IF SIZE <600 THEN PRINT "MEMORY LOW": PRINT
1280 IF SIZE <500 THEN PRINT "MEMORY CRITICAL": GOTO 500
1290 NL=NL+1
1291 REM ENABLE THE FOLLOWING LINE TO ECHO THE WRAPPED PRECEDING LINE
1295 REM PRINT:PRINT ">";T$()(NL-1);
1300 PRINT: PRINT ">";T$()(NL);
1310 GOTO 1020
1500 REM NEWLINE
1505 PUT CR: PUT LF
1510 NL=NL+1
1520 IF NL>24 THEN PRINT "BUFFER FULL": GOTO 500
1530 GOTO 1010
1600 REM BACKSPACE (CURRENT LINE ONLY)
1610 L=LEN(T$()(NL))
1615 IF L<1 GOTO 1020
1620 IF L=1 THEN T$()(NL)="": GOTO 1640
1625 SCRATCH$=LEFT$(T$()(NL),L-1)
1630 T$()(NL)=SCRATCH$
1640 PUT 8: PUT 32: PUT 8
1650 GOTO 1020
2999 REM EDIT MODE
3000 SEARCH$="": REPLACE$=""
3010 PRINT "EDIT MODE"
3020 PRINT "@=RETURN TO MENU"
3030 PRINT "C=CORRECT"
3040 FOR I=1 TO 24
3050 PRINT I,T$()(I)
3060 NEXT I
3070 GET W$
3080 IF W$="" THEN GOTO 3070
3090 IF W$="@" THEN GOTO 500
3100 IF W$="C" THEN GOTO 3200
3110 GOTO 3070
3200 PRINT "ERROR:"
3210 FOR ERRSTRING=1 TO 80
3220 GET J$
3230 IF J$="" THEN GOTO 3220
3240 IF J$=CHR$(4) THEN GOTO 3290
3250 IF J$=CHR$(BKSP) THEN SEARCH$=LEFT$(SEARCH$,LEN(SEARCH$)-1): GOTO 3270
3260 SEARCH$=SEARCH$+J$
3270 PRINT J$;
3280 NEXT ERRSTRING
3290 PRINT: PRINT "CORRECTION: "
3300 FOR ERRSTRING=1 TO 80
3310 GET J$
3320 IF J$="" THEN GOTO 3310
3330 IF J$=CHR$(4) THEN GOTO 3500
3340 IF J$=CHR$(BKSP) THEN REPLACE$=LEFT$(REPLACE$,LEN(REPLACE$)-1): GOTO 3360
3350 REPLACE$=REPLACE$+J$
3360 PRINT J$;
3370 NEXT ERRSTRING
3500 GOSUB 9000: REM CLEAR SCREEN
3510 PRINT "CORRECTING"
3520 FOR I=1 TO 24
3530 FOR J=1 TO LEN(T$()(I))
3540 O=LEN(SEARCH$)
3550 IF MID$(T$()(I),J,O)=SEARCH$ THEN OO=LEN(T$()(I))-J+1-O
3560 IF MID$(T$()(I),J,O)=SEARCH$ THEN C6$=RIGHT$(T$()(I),OO)
3570 IF MID$(T$()(I),J,O)=SEARCH$ THEN T$()(I)=LEFT$(T$()(I),J-1): GOTO 3590
3580 GOTO 3610
3590 T$()(I)=T$()(I)+REPLACE$+C6$: SEARCH$="": REPLACE$=""
3600 FOR H=1 TO I: PRINT T$()(H): NEXT H: GOTO 3020
3610 NEXT J
3620 NEXT I
3630 PRINT "ERROR STRING NOT FOUND": PRINT: GOTO 3020
3640 GOTO 3000
9000 PUT 27: PUT 91: PUT 50: PUT 74: RETURN: REM CLEAR SCREEN
Important Links
Git Repo
https://codeberg.org/vidak/peoples
Forum Thread Discussion
https://basiclang.solarpunk.au/d/4-the-peoples-permacomputer-project/15
VIC EDITYPE Historical Source Code
http://www.vic20listings.freeolamail.com/book_computevic2.html








