Page 1 of 2
Using & in a label
Posted: Tue Oct 07, 2014 8:53 am
by CalScot
Hi, everyone.
I think I've discovered a bug!
I'm using 3.3.1 and XP3.
When I use Property Edit to enter the value of a label, and I type in "&" (the ampersand) instead of "and", it shows properly in the edit box (and shows properly again if I go back to edit it) but it doesn't show correctly on the label. Instead, it shows a double space where the " & " should be.
For example, If I enter
"Checking for this & that..." in the property edit box, it shows up as
"Checking for this that..." on the label itself - before and after compiling.
It's not a big problem, but it would sometimes be nice to be able to save the 2 extra character spaces that using "&" instead of "and" allows.
Thanks and regards to you all.
Re: Using & in a label
Posted: Tue Oct 07, 2014 10:44 am
by mol
& in conjuction with next character works like a hot key for control next to label.
If you want to use pure & char, you should change value of label after defining it, I think.
Re: Using & in a label
Posted: Tue Oct 07, 2014 11:36 am
by CalScot
Thanks. MOL. I understand what you're saying, but this is done through the Property Edit feature of the Objects Inspector.
I haven't tried (yet) to see what happens if I define or edit it using an external text editor (i.e., outside of the Objects Inspector), but I will, to see if that leaves my label intact -- but I still think it's a system bug that needs to be fixed, in that it's interpreting (misinterpreting!) the text of the label as having a control character in it.
Thanks again.
Re: Using & in a label
Posted: Tue Oct 07, 2014 12:59 pm
by mol
It's very useful in my opinion, nt a bug.
But, it should exist a way to allow use "&" as common char, eg. \&;
something like html
Re: Using & in a label
Posted: Tue Oct 07, 2014 5:17 pm
by Rathinagiri
Hi,
Wherever you want & inside label/menu control please use &&.
Consider this:
Code: Select all
#include <hmg.ch>
Function Main
define window x at 0, 0 width 400 height 300 main
define label l1
row 10
col 10
width 200
value 'A Sample & Label'
end label
define label l2
row 40
col 10
width 200
value 'A Sample && Label'
end label
end window
x.Center
x.Activate
Return

- Clipboard01.jpg (9.95 KiB) Viewed 5030 times
Re: Using & in a label
Posted: Tue Oct 07, 2014 5:28 pm
by CalScot
Ah! I suspected that I couldn't have been the first to encounter this!
You've solved the spacing problem that led me to discover this.
Perfect solution!
Thank you Rathinagiri
Re: Using & in a label
Posted: Tue Oct 07, 2014 5:33 pm
by gfilatov
Rathinagiri wrote:Hi,
Wherever you want & inside label/menu control please use &&.
Consider this:
Hi,
Please be so kind to try also the updated sample below:
Code: Select all
#include <hmg.ch>
Function Main
define window x at 0, 0 width 400 height 300 main
define label l1
row 10
col 10
width 200
value 'A Sample & Label'
NOPREFIX .T.
end label
define label l2
row 40
col 10
width 200
value 'A Sample && Label'
end label
end window
x.Center
x.Activate
Return Nil
Re: Using & in a label
Posted: Tue Oct 07, 2014 5:42 pm
by Rathinagiri
Awesome Grigory! Thanks!
Re: Using & in a label
Posted: Tue Oct 07, 2014 6:11 pm
by mol
Thanks for info!
I'm still learning and still foolish

Re: Using & in a label
Posted: Tue Oct 07, 2014 6:34 pm
by CalScot
Not at all foolish, MOL!

We all live and learn. (And sometimes forget!)
And I absolutely agree about having & as an operator/evaluator - I use it a lot! I'm just surprised that I haven't had (or don't remember?) the issue of it being inside a string before now!
I even tried (before posting) to search this site for "& in a label", but as the search stripped out the "& in a", that didn't help me much. And I can't see a way around that, either! Who can find this thread if they search for it using "&" as a key word?
But my concern (it wasn't really a "problem") is resolved, so thanks to all for that.
Now I need to go and check out Grigory's "NOPREFIX .T." addition

Thanks again.
CalScot