Problem with (grammatical) person changing program
(no login) Posted Jul 19, 2012 4:34 PM
I had written a program to change the person of any text from 1st to 2nd person (you becomes I etc.)
For some reason it isn't working (i've written the details in the comments of the code) and i don't understand why
Thanks
Source Code:
PRINT changePerson$("your my your my mine yours")
'should be changed to "my your my your yours mine"
'right now it's change to "my,my,my,my,mine,yours"
'the last word isn't being changed and the words in first person
'aren't being changed to second person
FUNCTION changePerson$ (toChange$)
DIM space(1000)
DIM word$(1000)
changed$ = ""
space(0) = 0
spacenum = 0
FOR x = 1 TO LEN(toChange$) 'loop continues until end of command
IF RIGHT$(LEFT$(toChange$, x), 1) = " " THEN 'finds a space
spacenum = spacenum + 1
space(spacenum) = x
word$(spacenum) = RIGHT$(LEFT$(toChange$, space(spacenum) - 1), space(spacenum) - space(spacenum - 1) - 1)
IF LCASE$(word$(spacenum)) = "i" THEN word$(spacenum) = "you"
IF LCASE$(word$(spacenum)) = "my" THEN word$(spacenum) = "your"
IF LCASE$(word$(spacenum)) = "mine" THEN word$(spacenum) = "yours"
IF LCASE$(word$(spacenum)) = "me" THEN word$(spacenum) = "you"
IF LCASE$(word$(spacenum)) = "myself" THEN word$(spacenum) = "yourself"
IF LCASE$(word$(spacenum)) = "you" THEN word$(spacenum) = "me"
IF LCASE$(word$(spacenum)) = "yours" THEN word$(spacenum) = "mine"
IF LCASE$(word$(spacenum)) = "your" THEN word$(spacenum) = "my"
changed$ = changed$ + word$(spacenum) + " "
END IF
NEXT x
spacenum = spacenum + 1
word$(spacenum) = LTRIM$(RIGHT$(toChange$, LEN(toChange$) - space(spacenum - 1)))
IF LCASE$(word$(spacenum)) = "you" THEN word$(spacenum) = "me"
IF LCASE$(word$(spacenum)) = "yours" THEN word$(spacenum) = "mine"
IF LCASE$(word$(spacenum)) = "your" THEN word$(spacenum) = "my"
IF LCASE$(word$(spacenum)) = "i" THEN word$(spacenum) = "you"
IF LCASE$(word$(spacenum)) = "my" THEN word$(spacenum) = "your"
IF LCASE$(word$(spacenum)) = "mine" THEN word$(spacenum) = "yours"
IF LCASE$(word$(spacenum)) = "me" THEN word$(spacenum) = "you"
IF LCASE$(word$(spacenum)) = "myself" THEN word$(spacenum) = "yourself"
changed$ = changed$ + word$(spacenum)
changePerson$ = changed$
END FUNCTION