Problem with (grammatical) person changing programby (no login)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 |
| Response Title | Author and Date |
| *Classic case of 'too many IF-THENs' | AlGoreIthm on Jul 19 |
| *I concur. SELECT CASE is the way to go here. | on Jul 19 |
| ... nope ... | AlGoreIthm on Jul 19 |
| alternative | AlGoreIthm on Jul 19 |
| Re: alternative | on Jul 20 |
| Yes | AlGoreIthm on Jul 20 |
| Re: Yes | on Jul 20 |
| program not undestood. | on Jul 21 |
| Please ... | on Jul 21 |
| Re: Please ... | on Jul 21 |
| Very well | AlGoreIthm on Jul 21 |
| Is this even possible? | Anon on Jul 24 |
| The MID$ statement can only swap strings of same length | on Jul 25 |
| it's more complicated than it looks | AlGoreIthm on Jul 25 |
| You can figure out the words, here's a function | on Jul 25 |
| This is just a basic version | on Jul 25 |