Longest string challenge: Difference between revisions
Content deleted Content added
Added various BASIC dialects (BASIC256, Chipmunk Basic, GW-BASIC and MSX Basic) |
|||
Line 648: | Line 648: | ||
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|BASIC256}}=== |
|||
<syntaxhighlight lang="vb">dim test = {"a", "bb", "ccc", "ddd", "ee", "f", "ggg"} |
|||
test1 = "" |
|||
for c = 0 to test[?]-1 |
|||
if length(test[c]) > length(test1) Then |
|||
test1 = test[c] |
|||
test2 = test1 & chr(10) |
|||
else |
|||
if length(test[c]) = length(test1) then test2 += test[c] & chr(10) |
|||
end if |
|||
next c |
|||
print test2 |
|||
end</syntaxhighlight> |
|||
==={{header|Chipmunk Basic}}=== |
|||
{{works with|Chipmunk Basic|3.6.4}} |
|||
<syntaxhighlight lang="qbasic">10 data "a","bb","ccc","ddd","ee","f","ggg","~" : ' la tilde es solo para mantener el código compacto |
|||
20 restore |
|||
30 read test$ |
|||
40 if test$ = "~" then goto 70 |
|||
50 if len(test$) > len(test1$) then test1$ = test$ : test2$ = test1$+chr$(10) else if len(test$) = len(test1$) then test2$ = test2$+test$+chr$(10) |
|||
60 goto 30 |
|||
70 print test2$ |
|||
80 end</syntaxhighlight> |
|||
==={{header|GW-BASIC}}=== |
|||
{{works with|PC-BASIC|any}} |
|||
{{works with|BASICA}} |
|||
{{works with|Chipmunk Basic}} |
|||
{{works with|QBasic}} |
|||
<syntaxhighlight lang="qbasic">10 DATA "a","bb","ccc","ddd","ee","f","ggg","~" |
|||
20 RESTORE |
|||
30 READ TEST$ |
|||
40 IF TEST$ = "~" THEN GOTO 80 |
|||
50 IF LEN(TEST$) > LEN(TEST1$) THEN LET TEST1$ = TEST$ : LET TEST2$ = TEST1$ + CHR$(10) : GOTO 30 |
|||
60 IF LEN(TEST$) = LEN(TEST1$) THEN LET TEST2$ = TEST2$ + TEST$ + CHR$(10) |
|||
70 GOTO 30 |
|||
80 PRINT TEST2$ |
|||
90 END</syntaxhighlight> |
|||
==={{header|MSX Basic}}=== |
|||
{{works with|MSX BASIC|any}} |
|||
{{works with|Applesoft BASIC}} |
|||
<syntaxhighlight lang="qbasic">10 DATA "a","bb","ccc","ddd","ee","f","ggg","~" |
|||
30 READ T$ |
|||
40 IF T$ = "~" THEN GOTO 80 |
|||
50 IF LEN(T$) > LEN(T1$) THEN LET T1$ = T$ : LET T2$ = T1$ + CHR$(10) : GOTO 30 |
|||
60 IF LEN(T$) = LEN(T1$) THEN LET T2$ = T2$ + T$ + CHR$(10) |
|||
70 GOTO 30 |
|||
80 PRINT T2$ |
|||
90 END</syntaxhighlight> |
|||
==={{header|QBasic}}=== |
==={{header|QBasic}}=== |