Using & in a label

Moderator: Rathinagiri

User avatar
CalScot
Posts: 303
Joined: Thu Mar 21, 2013 12:22 am
Location: California

Using & in a label

Post 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.
User avatar
mol
Posts: 3774
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Using & in a label

Post 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.
User avatar
CalScot
Posts: 303
Joined: Thu Mar 21, 2013 12:22 am
Location: California

Re: Using & in a label

Post 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.
User avatar
mol
Posts: 3774
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Using & in a label

Post 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
User avatar
Rathinagiri
Posts: 5480
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Using & in a label

Post 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
Clipboard01.jpg (9.95 KiB) Viewed 5029 times
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
CalScot
Posts: 303
Joined: Thu Mar 21, 2013 12:22 am
Location: California

Re: Using & in a label

Post 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
User avatar
gfilatov
Posts: 1090
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Using & in a label

Post 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
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
Rathinagiri
Posts: 5480
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Using & in a label

Post by Rathinagiri »

Awesome Grigory! Thanks!
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3774
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Using & in a label

Post by mol »

Thanks for info!
I'm still learning and still foolish :-D
User avatar
CalScot
Posts: 303
Joined: Thu Mar 21, 2013 12:22 am
Location: California

Re: Using & in a label

Post 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
Post Reply