Longest string challenge: Difference between revisions
Content deleted Content added
Applesoft BASIC |
m make all literals INT(VAL("number")) |
||
Line 625: | Line 625: | ||
REM OUTPUT THE MESSAGE TO THE TOP OF THE TEXT SCREEN |
REM OUTPUT THE MESSAGE TO THE TOP OF THE TEXT SCREEN |
||
130 IT$ = "12345678901234567890123" |
130 IT$ = "12345678901234567890123" |
||
140 TEXT : HOME : VTAB |
140 TEXT : HOME : VTAB TWO%: POKE 34,UN% |
||
REM + IS A "STRING" OPERATOR, A NON-ARITHMETIC OPERATOR WHEN USED WITH STRINGS FOR CONCATENATION |
REM + IS A "STRING" OPERATOR, A NON-ARITHMETIC OPERATOR WHEN USED WITH STRINGS FOR CONCATENATION |
||
150 IT$ = IT$ + "." |
150 IT$ = IT$ + ".": REM + MEANS CONCATENATE, A "STRING" OPERATOR, A NON-ARITHMETIC OPERATOR |
||
160 P% = INT ( VAL ("10" + STR$ ( LEN (IT$)))) |
160 P% = INT ( VAL ("10" + STR$ ( LEN (IT$)))) |
||
170 POKE P%, INT ( ASC ( LEFT$ (MSG$,UN%))) |
170 POKE P%, INT ( ASC ( LEFT$ (MSG$,UN%))) |
||
Line 643: | Line 643: | ||
280 IF INT ( LEN (IT$)) GOTO 210"READ NEXT LINE IF LESS THAN LONGEST STRING |
280 IF INT ( LEN (IT$)) GOTO 210"READ NEXT LINE IF LESS THAN LONGEST STRING |
||
REM EQUAL TO LONGEST STRING |
REM EQUAL TO LONGEST STRING |
||
290 RESULT$ = RESULT$ + CHR$ (13) + STD$: GOTO 210"READ NEXT LINE |
290 RESULT$ = RESULT$ + CHR$ (INT ( VAL ("13"))) + STD$: GOTO 210"READ NEXT LINE |
||
REM REMOVE A CHARACTER FROM BOTH IF THEY STILL HAVE LENGTH |
REM REMOVE A CHARACTER FROM BOTH IF THEY STILL HAVE LENGTH |
||
300 IF INT ( LEN (IT$)) THEN IT$ = MID$ (IT$,TWO%):COMPARE$ = MID$ (COMPARE$,TWO%): GOTO 270"COMPARE AGAIN |
300 IF INT ( LEN (IT$)) THEN IT$ = MID$ (IT$,TWO%):COMPARE$ = MID$ (COMPARE$,TWO%): GOTO 270"COMPARE AGAIN |
||
Line 655: | Line 655: | ||
REM CLEAR THE MESSAGE FROM THE TEXT SCREEN |
REM CLEAR THE MESSAGE FROM THE TEXT SCREEN |
||
520 V% = INT ( PEEK ( INT ( VAL ("37")))) |
520 V% = INT ( PEEK ( INT ( VAL ("37")))) |
||
530 TEXT : VTAB |
530 TEXT : VTAB UN%: CALL INT ( VAL ("-868")) |
||
540 VTAB V%: CALL |
540 VTAB V%: CALL INT ( VAL ("-912")) |
||
REM ERROR CODE 255 |
REM ERROR CODE 255 |
||
550 IT$ = "12345678901234567" |
550 IT$ = "12345678901234567" |
||
Line 670: | Line 670: | ||
620 IF INT ( LEN (IT$)) THEN COMPARE$ = MID$ (COMPARE$,TWO%): GOTO 590"COMPARE AGAIN |
620 IF INT ( LEN (IT$)) THEN COMPARE$ = MID$ (COMPARE$,TWO%): GOTO 590"COMPARE AGAIN |
||
630 PRINT RESULT$</syntaxhighlight> |
630 PRINT RESULT$</syntaxhighlight> |
||
==={{header|True BASIC}}=== |
==={{header|True BASIC}}=== |
||
{{trans|FreeBASIC}} |
{{trans|FreeBASIC}} |