Andrew,
It's a doc error. - removes the trailing spaces from the first operand and concatenates them to end of the result. This is ostensibly to create fixed width results. Since it's the same precedence level as +, they evaluate left to right. This explains why the third result has the embedded spaces.
>I've just been showing off VFP's great string handling capabilities to the class here in sunny Melbourne. Of course, I got side tracked and set a litle exercise to demo the difference between the - and + operators:
>
m.lcString1 = "Hello" + space(4)
>m.lcString2 = "World" + space(2)
>? "*" + m.lcString1 + m.lcString2 + "*"
>? len("*" + m.lcString1 + m.lcString2 + "*")
>? "*" + m.lcString1 - m.lcString2 + "*"
>? len("*" + m.lcString1 - m.lcString2 + "*")
>? "*" + m.lcString1 - space(1) + m.lcString2 - "*"
>? len("*" + m.lcString1 - space(1) + m.lcString2 - "*")
>Pretty normal sort of stuff
>This returns:
>
>18
>*HelloWorld *
>18
>*Hello World*
>19
where I would expect it to return
>
>18
>*HelloWorld *
>14
>*Hello World*
>13
>This occurs in VFP5 and 7.
>From my reading of the docs, the - operator should "remove the trailing blanks from the element preceeding the operator, then join the two elements". What appears to be occurring is that the string is left the same length and the white space simply moved to the end.
>Anyone else consider this to be a bug, either in the docs or the program?