10 :REM********************* MBASEDIT.BAS ************************
20 :REM*		AL BRENDEL 3/15/81
30 :REM* A DATA ENTRY AND EDITING SUBROUTINE FOR MBASIC 5.X
40 :REM* FOR TERMINALS WITH OR WITHOUT CURSOR CONTROL
50 :REM* ESPECIALLY USEFUL FOR GETTING OR EDITING DATA WITH FIXED
60 :REM* FIELD LENGTHS FOR FORM PRINTING OR RANDOM ACCESS FILES
70 :REM* ( SEE ALSO CBASEDIT.BAS FOR C-BASIC2 VERSION )
80 :REM* 
90 :REM*************** TEST OF THE BASEDIT FUNCTION *******************
100 :REM
110 DATA NUMBER 1 = ,12345,10
120 DATA NUMBER 2 = ,1234567890,20
130 DATA NUMBER 3 = ,ABCDEFG,30
140 FOR X=1 TO 3
150 READ MSG$,NAM$,LENGTH
160 GOSUB 1000
170 ANS$(X)=NAM$
180 NEXT
190 PRINT ANS$(1),ANS$(2),ANS$(3)
200 END
1000 : 	REM ********** GET DATA AND EDIT FUNCTION *************
1010 : 	REM *TYPICAL APPLICATION:
1020 : 	REM	MSG$="EDIT..":NAM$="1234":LENGTH=20:GOSUB 1000
1030 : 	REM		'PRINTS MSG AND THEN ALLOWS
1040 : 	REM		'ENTRY OR MODIFICATION OF NAM$ AND
1050 : 	REM		'SHOWS LENGTH OF FIELD
1060 : 	REM		'EDITING COMMANDS INCLUDE:
1070 : 	REM			'MOVE CURSER RIGHT..	>
1080 : 	REM			'MOVE CURSER LEFT...	< OR BS(^H)
1090 : 	REM			'DELETE CHARACTER...	DEL
1100 : 	REM			'INSERT CHARACTER...	^
1110 : 	REM			'RETURN TO PROGRAM...	CR
1120 : 		NAM$=NAM$+STRING$(LENGTH-LEN(NAM$),42)
1130 : 		PRINT MSG$;": ";NAM$+STRING$(LENGTH,8);
1140 : 		FOR NUM = 1 TO LENGTH
1150 : 		ANS%=ASC(INPUT$(1)):PRINT CHR$(ANS%);
1160 : 		IF ANS%=13 THEN GOTO 1280
1170 : 		IF ANS%=8 AND NUM=1 THEN PRINT

			 CHR$(32)+MID$(NAM$,NUM,1)+CHR$(8);

			 :NUM=NUM-1:GOTO 1270
1180 : 		IF ANS%=8 THEN NUM=NUM-2 :GOTO 1270
1190 :		IF ANS%=62 AND NUM=LENGTH THEN PRINT CHR$(8)

			+MID$(NAM$,NUM,1)+CHR$(8)+CHR$(7);

			:NUM=NUM-1:GOTO 1270
1200 : 		IF ANS%=62 THEN PRINT CHR$(8)+ MID$(NAM$,NUM,1);:GOTO 1270
1210 : 		IF ANS%=60 AND NUM>1 THEN PRINT CHR$(8)+

			 MID$(NAM$,NUM,1)+CHR$(8)+CHR$(8);

			 :NUM=NUM-2:GOTO 1270
1220 : 		IF ANS%=60 AND NUM=1 THEN PRINT CHR$(8)

			+MID$(NAM$,NUM,1)+CHR$(8); 

			:NUM=NUM-1:GOTO 1270
1230 : 		IF ANS%=94 THEN NAM$=LEFT$(NAM$,NUM-1)

			 +" "+MID$(NAM$,NUM,LENGTH-NUM)

			 :PRINT CHR$(8)+RIGHT$(NAM$,LENGTH-NUM+1)

			 +STRING$(LENGTH-NUM+1,8);

			 :NUM=NUM-1:GOTO 1270
1240 : 		IF ANS%=127 THEN NAM$=LEFT$(NAM$,NUM-1)

			 +RIGHT$(NAM$,LENGTH-NUM)+"*"

			 :PRINT RIGHT$(NAM$,LENGTH-NUM+1)

			 +STRING$(LENGTH-NUM+1,8);

			 :NUM=NUM-1:GOTO 1270
1250 : 		NAM$=LEFT$(NAM$,NUM-1) +CHR$(ANS%)+RIGHT$(NAM$,LENGTH-NUM)
1260 : 		IF NUM=LENGTH THEN PRINT CHR$(7)+CHR$(8);:NUM=NUM-1
1270 : 		NEXT NUM
1280 : 		FOR NUM=1 TO LENGTH
1290 : 			IF MID$(NAM$,NUM,1)="*" THEN NAM$= 

				LEFT$(NAM$,NUM-1)+" "

				+RIGHT$(NAM$,LENGTH-NUM)
1300 : 		NEXT NUM
1310 : 		PRINT MSG$;": ";NAM$
1320 : 		RETURN
1330 : 
FT$(NAM$,NUM-1)+" "

				+RIGHT$(NAM$,LENGTH-NU