100 REM Purpose: Verify NULL character and MAXLEN strings
110 REM  Author: Howard Wulf, AF5NE
120 REM    Date: 2015-03-02
130 REM
140 M = MAXLEN("")
150 PRINT "MAXLEN=";M
160 ' maintainer debug on
170 ON ERROR GOTO 8000
200 REM Verify length is 11
210 LET A$ = "12345" + CHR$(0) + "67890"
220 LET N = LEN(A$)
230 PRINT N
235 IF N <> 11 THEN 9999
236 PRINT "TEST #1 OK"
300 REM Verify length is MAXLEN
310 LET A$ = STRING$( M, 0 )
320 LET N = LEN(A$)
330 PRINT N
335 IF N <> M THEN 9999
336 PRINT "TEST #2 OK"
400 REM Verify length is MAXLEN
410 A$ = A$ + "*"
420 LET N = LEN(A$)
430 PRINT N
435 IF N <> M THEN 9999
436 PRINT "TEST #3 OK"
500 REM Verify length is MAXLEN
510 A$ = A$ + A$
520 LET N = LEN(A$)
530 PRINT N
535 IF N <> M THEN 9999
536 PRINT "TEST #4 OK"
600 REM Verify length is MAXLEN
610 A$ = A$ + ""
620 LET N = LEN(A$)
630 PRINT N
635 IF N <> M THEN 9999
636 PRINT "TEST #5 OK"
700 REM Verify length is MAXLEN
710 A$ = "" + A$
720 LET N = LEN(A$)
730 PRINT N
735 IF N <> M THEN 9999
736 PRINT "TEST #6 OK"
800 REM Verify length is MAXLEN
810 A$ = A$ + CHR$(0)
820 LET N = LEN(A$)
830 PRINT N
835 IF N <> M THEN 9999
836 PRINT "TEST #7 OK"
900 REM Verify length is MAXLEN
910 A$ = CHR$(0) + A$
920 LET N = LEN(A$)
930 PRINT N
935 IF N <> M THEN 9999
936 PRINT "TEST #8 OK"
1000 REM Verify length is MAXLEN - 1
1010 A$ = LEFT$( STRING$(M,0), M - 1 )
1020 LET N = LEN(A$)
1030 PRINT N
1035 IF N <> M - 1 THEN 9999
1036 PRINT "TEST #9 OK"
1100 REM Verify length is MAXLEN - 1
1110 A$ = RIGHT$( STRING$(M,0), M - 1 )
1120 LET N = LEN(A$)
1130 PRINT N
1135 IF N <> M - 1 THEN 9999
1136 PRINT "TEST #10 OK"
1200 REM Verify length is MAXLEN
1210 A$ = MID$( STRING$(M,0), 1, M )
1220 LET N = LEN(A$)
1230 PRINT N
1235 IF N <> M THEN 9999
1236 PRINT "TEST #11 OK"
1300 REM Verify length is MAXLEN - 1
1310 A$ = MID$( STRING$(M,0), 2, M )
1320 LET N = LEN(A$)
1330 PRINT N
1335 IF N <> M - 1 THEN 9999
1336 PRINT "TEST #12 OK"
1400 REM  Verify length is MAXLEN
1410 A$ = MID$( A$, 1, M ) + MID$( A$, 2, M )
1420 LET N = LEN(A$)
1430 PRINT N
1435 IF N <> M THEN 9999
1436 PRINT "TEST #13 OK"
2000 REM Verify EVERY char is NULL
2005 REM PRINT "M=";M
2010 PRINT "         1         2         3         4"
2020 PRINT "1234567890123456789012345678901234567890"
2030 FOR I = 1 TO M
2040 IF I MOD 100 = 0 THEN
2050   PRINT ".";
2060 END IF
2070 IF ASC(MID$(A$,I,1)) <> 0 THEN
2080   PRINT "*** ERROR AT I=";I
2090   STOP
2100 END IF
2110 NEXT I
2120 PRINT
2130 REM 
2136 PRINT "TEST #14 OK"
2199 GOTO 9000
8000 REM ERROR HANDLER
8010 PRINT "ERR=";ERR,"ERL=";ERL
8020 RESUME NEXT
9000 PRINT "*** ALL TESTS PASSED ****"
9999 END
