Proof of how you're wrong:
Code:
Clear
?
_screen.addobject("label1")
_screen.label1.visible = .T.
_screen.label1.caption = 'example'+'x'
_screen.caption = 'example'+'x'
? 'example'+'x'
? len('example'+'x')
? ' ' $ 'example'+'x'
? Occurs(' ','example'+'x')
This is what you end up with:
View attachment 2445
All concatenations of 'example'+'x' won't contain a space. Not on a form caption, not on a label caption, nor if printed. The expression 'example'+'x' concatenates an x to example, making it examplex. Straight forward, nothing surprising happening here, no bug, no special behavior of labels or anything else. What do you see here on the result screenshot? 1. The _screen caption has become examplex, no space. 2. The label caption (that's the first line after the toolbar icons) as examplex, no space, directly printing with ? shows examplex without space, the length of the expression is 8 (7 from 'example', 1 from 'x', 7+1=8), no space. The $ operator (to explain it: a $ b means asking the quesstion "is a contained in b?") results in .F. (false), there is no space. The Occurs() functions returns 0, meaning there are 0 spaces in 'example'+'x' (the first parameter is searched in the second and the number of occurrances is returned).
When you see a space, there has been a space. Likely after 'example', maybe even two or three.
You didn't literally put in two strings, did you? The way you use in your example is not what you really did. You got the first and maybe also the second part of the caption from fields of tables. And those are likely char fields? Am I guessing right? See what happens in such a case:
Code:
Create Cursor captionparts (part1 c(10), part2 c(10))
Insert into captionparts values ('example','x')
? part1+part2
Of course you're not having eactly this, but when you get part of a caption from a field, think about what happens. How does the space come in here? That's the quiz question, now. Can you answer it?
And regarding your problem: Don't make assumptions and guesses, don't oversimplify your question, we can only answer it, if you honestly tell us how the caption is put together. General rule: There is nothing about a label that automatically adds to what you put into its caption property, you can see the caption property as if it was a string variable, so any string operations like string concatenation with the + operator work in the same manner as if you'd directly output the expression with ? or put it into a normal variable or any other caption like a form caption, or also a textbox.value or whatever else you pick that can store a string. String operations just work the way they work, no bug, no magic, no automatism. You're not seeing the woods for the tree, here. Open your eyes.
And if you want an answer, tell us what's actually put together to a label caption, don't give an example which you can easily test for yourself does not have the effect you saw. How can we answer what to change if what you post is not even remotely what you do? Once you would just check your own example, see that it doesn't show the effect, then also don't post it. Post closer to what you do, really. As this doesn't fail, you have to wshow more. So the reason has to be something else. We can't tell you what's wrong with your actual code, if you don't post it. And it's obvious you didn't.
I demonstrated one way you get spaces into an expression without having spaces in the strings that make up the code. Again, can you answer the quiz question? It's fun, once you find out yourself. I think you've already been told too look out for all the details including how data types work. If you find the basics of these things too boring to learn, you can't even do a string concatenation without being surprised about the result. You lack just a tiny bit of information, but you see how this puzzles you. Just because this is too boring for you. Find something that is interesting for you and learn that, you're not able to learn programming, if you fail on such low levels of analyzing what happens and why.