g$="happy halloween my fellow programmers " REPEAT h$=FNnxtwrd(g$) IF h$<>"" THEN PRINT h$ UNTIL h$="" END DEFFNnxtwrd(c$) PRIVATE cnt% LOCAL ret$ cnt%=cnt%+1 WHILE MID$(c$,cnt%,1)<>" " ret$=ret$+MID$(c$,cnt%,1) cnt%=cnt%+1 ENDWHILE IF ret$="" THEN cnt%=0 =ret$
g$="happy halloween my fellow programmers " amnt%=0 REPEAT h$=FNnxtwrd(g$) REM you could replace the following line with the sample line I shown in the description IF h$<>"" THEN PRINT h$:amnt%+=1 UNTIL h$="" PRINT "There are "+STR$(amnt%)+" words in the sentence." END DEFFNnxtwrd(c$) PRIVATE cnt% LOCAL ret$ cnt%=cnt%+1 WHILE MID$(c$,cnt%,1)<>" " ret$=ret$+MID$(c$,cnt%,1) cnt%=cnt%+1 ENDWHILE IF ret$="" THEN cnt%=0 =ret$
g$="happy halloween my fellow programmers " INSTALL @lib$+"stringlib" g$=FN_trim(g$) : REM remove leading and trailing spaces, (if any) WHILE FN_findreplace(g$," "," ",0) : ENDWHILE : REM make sure there is only one space between words, (if needed) PRINT FN_split(g$," ",a$()) : REM count words