LET sstring$ = "rosetta code phrase reversal" !The string LET sNewString$ = "" !String variables LET sTemp$ = "" !Temporary string variable LET siCount = 0 !Counter DIM sword$(0 to 100) !Word store LET i = 0 !Index variable LET startPos = 1 !Start position for word extraction LET endPos = 0 !End position for word extraction LET wordCount = 0 !Number of words ! Loop backwards through the string FOR sicount = round(len(sstring$)) to 1 step -1 LET snewstring$ = snewstring$ & (sstring$)[sicount:sicount+1-1] !Add each character to the new string NEXT sicount PRINT "Original string => " & sstring$ !Print the original string PRINT "Reversed string => " & snewstring$ !Print the reversed string LET snewstring$ = "" !Reset sNewString ! Manually split the original string by spaces FOR i = 1 to round(len(sstring$)) IF (sstring$)[i:i+1-1] = " " or i = len(sstring$) then IF i = len(sstring$) then LET endpos = i else LET endpos = i-1 LET sword$(wordcount) = (sstring$)[startpos:startpos+endpos-startpos+1-1] LET wordcount = wordcount+1 LET startpos = i+1 END IF NEXT i ! Loop backward through each word in sWord FOR sicount = wordcount-1 to 0 step -1 LET snewstring$ = snewstring$ & sword$(sicount) & " " !Add each word to sNewString NEXT sicount PRINT "Reversed order => " & snewstring$ !Print reversed word order LET snewstring$ = "" !Reset sNewString ! For each word in sWord FOR i = 0 to wordcount-1 LET stemp$ = sword$(i) ! Loop backward through the word FOR sicount = round(len(stemp$)) to 1 step -1 LET snewstring$ = snewstring$ & (stemp$)[sicount:sicount+1-1] !Add the characters to sNewString NEXT sicount LET snewstring$ = snewstring$ & " " !Add a space at the end of each word NEXT i PRINT "Reversed words => " & snewstring$ !Print words reversed END