RosettaCodeData/Task/Ordered-words/Liberty-BASIC/ordered-words.basic
2023-07-01 13:44:08 -04:00

33 lines
721 B
Text

'Ordered wordsFrom Rosetta Code
open "unixdict.txt" for input as #1
'this is not normal DOS/Windows file.
'It LF delimited, not CR LF
'So Line input would not work.
lf$=chr$(10)
curLen=0
wordList$=""
while not(eof(#1))
a$=inputto$(#1, lf$)
'now, check word
flag = 1
c$ = left$(a$,1)
for i = 2 to len(a$)
d$ = mid$(a$,i,1)
if c$>d$ then flag=0: exit for
c$=d$
next
'ckecked, proceed if ordered word
if flag then
if curLen=len(a$) then
wordList$=wordList$+" "+a$
else
if curLen<len(a$) then
curLen=len(a$)
wordList$=a$
end if
end if
end if
wend
close #1
print wordList$