Page 1 of 1

& in label

Posted: Sat Sep 30, 2017 1:24 am
by franco
Hi all,
I have run into something I can not figure out.
I have a label on a form
I have a customer`s name "G&G name"
when I say form.label.value := "Customer: "+customer->name
the label will not show the & the labels value becomes GG name.
any ideas;
Thanx .. Franco ;)

Re: & in label

Posted: Sat Sep 30, 2017 7:20 am
by mol
Transform & to && before writing to label value

Code: Select all

form.label.value := "Customer: "+strtran(customer->name, "&", "&&")

Re: & in label

Posted: Sat Sep 30, 2017 11:30 am
by gfilatov
franco wrote: Sat Sep 30, 2017 1:24 am the label will not show the &
any ideas;
Thanx ..
Hello Franco,

Try to add the NOPREFIX clause to your Label definition. :o

Hope that helps :idea:

Re: & in label

Posted: Sat Sep 30, 2017 6:58 pm
by franco
Merek, this solved my problem. Thank you
Grigory I tried to add this but does not work for me . Where exactly do you add this clause.
Thanks again ......... Franco

Re: & in label

Posted: Sat Sep 30, 2017 8:59 pm
by KDJ
Franco
Here is an example:

Code: Select all

#include "hmg.ch"

MEMVAR _HMG_SYSDATA

FUNCTION Main()
  LOCAL cText := "G&G name"

  DEFINE WINDOW MainWnd;
    ROW    100;
    COL    100;
    WIDTH  180;
    HEIGHT 120;
    TITLE  "NOPREFIX label";
    MAIN;
    NOSIZE;
    NOMINIMIZE;
    NOMAXIMIZE

    DEFINE LABEL Text1
      ROW      20
      COL      20
      WIDTH    140
      VALUE    cText
      NOPREFIX .F.
    END LABEL

    DEFINE LABEL Text2
      ROW      50
      COL      20
      WIDTH    140
      VALUE    cText
      NOPREFIX .T.
    END LABEL
  END WINDOW

  MainWnd.ACTIVATE

RETURN NIL

Re: & in label

Posted: Sun Oct 01, 2017 4:02 am
by franco
Now I understand.
Thanks to all.