Compare length of two strings: Difference between revisions

Line 327:
10 'SAVE "SSTRING",A
20 ' Length of a group of strings
4030 OPTION BASE 1
30 CLS
5040 DIM SSTRING$(10)
40 OPTION BASE 1
6050 I=0: J=1
50 DIM SSTRING$(10)
60 ' Begin of program cycle
60 I=0: J=1
70 ' DoCLS
80 PRINT "CaptureThis program shows the string";J;"(length of up to 10, Enter tocaptured finish)strings.";
90 PRINT "Enter an empty string to finish anytime."
90 INPUT SSTRING$(J)
100 PRINT
100 IF SSTRING$(J)="" THEN 150 ' Exit Do
110 ' Do
110 IF J>1 THEN GOSUB 250 ' Autosort
120 JPRINT ="Capture the string";STR$(J);": + 1";
130 IF J <INPUT 11"", THEN 70 ' LoopSSTRING$(J)
100140 IF SSTRING$(J)="" THEN 150180 ' Exit Do
150 ' Show results
110150 IF J>1 THEN GOSUB 250280 ' Autosort
160 CLS
170160 J = J -+ 1
180170 IF J <1 11 THEN PRINT "You entered no strings.":110 GOTO' 230Loop
150180 ' Show results
190 PRINT "You entered";J;"strings. Lengths are as follows:"
30190 CLS
200 FOR I=1 TO J
200 J = J - 1
210 PRINT USING "##. &: ## chars."; I;SSTRING$(I);LEN(SSTRING$(I))
210 IF J<1 THEN PRINT "You entered no strings.": GOTO 260
220 NEXT I
190220 PRINT "You entered";J;"strings. Lengths are as follows:"
230 PRINT: PRINT "End of program execution."
200230 FOR I=1 TO J
240 END
210240 PRINT USING "##. &: ## chars."; I;SSTRING$(I);LEN(SSTRING$(I))
250 ' Autosort subroutine
260 250 NEXT I=J
230260 PRINT: PRINT "End of program execution."
270 WHILE I>1
240270 END
280 IF LEN(SSTRING$(I)) > LEN(SSTRING$(I-1)) THEN SWAP SSTRING$(I), SSTRING$(I-1)
250280 ' Autosort subroutine
290 I=I-1
300290 WENDI=J
270300 WHILE I>1
310 RETURN
280310 IF LEN(SSTRING$(I)) > LEN(SSTRING$(I-1)) THEN SWAP SSTRING$(I), SSTRING$(I-1)
290320 I=I-1
330 WEND
310340 RETURN
</syntaxhighlight>
{{out}}
The user enters a list of up to 10 strings
<pre>
CaptureThis program shows the stringlength 1of (up to 10, Enter to finish)?captured abcdstrings.
CaptureEnter thean empty string 2 (up to 10, Enter to finish)? 123456789anytime.
 
Capture the string 3 (up to 10, Enter to finish)? abcdef
Capture the string 41: (up to 10, Enter to finish)? 1234567abcd
Capture the string 4 (up to 10, Enter to finish)?2: 123456789
Capture the string 3 (up to 10, Enter to finish)?: abcdef
Capture the string 4: 1234567
Capture the string 5:
 
You entered 4 strings. Lengths are as follows:
58

edits