Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
String Concatenation with the - Operator
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00674235
Message ID:
00674238
Vues:
19
Yep, strange results...

>Hi Folks,
>
>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:
>
*Hello    World  *
>18
>*HelloWorld      *
>18
>*Hello     World*
>19
where I would expect it to return
>
*Hello    World  *
>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?
>
>Cheers,
>
>Andrew
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform