& in label

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

& in label

Post 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 ;)
All The Best,
Franco
Canada
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: & in label

Post by mol »

Transform & to && before writing to label value

Code: Select all

form.label.value := "Customer: "+strtran(customer->name, "&", "&&")
User avatar
gfilatov
Posts: 1060
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: & in label

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

"Everything should be made as simple as possible, but no simpler." Albert Einstein
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: & in label

Post 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
All The Best,
Franco
Canada
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: & in label

Post 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
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: & in label

Post by franco »

Now I understand.
Thanks to all.
All The Best,
Franco
Canada
Post Reply