How I can to send a varieble to LABEL?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
Jairo Maia
Posts: 53
Joined: Sun Jul 17, 2011 1:47 pm
Location: Campinas - SP - Brazil

How I can to send a varieble to LABEL?

Post by Jairo Maia »

There are a way for me to send a variable in LABEL? E.g.:

Code: Select all

Label_Definition := "Label_Name"

@ 10,10 LABEL Label_Definition	;
		            VALUE 'Name'		;
		            WIDTH 140		;
		            HEIGHT 30		;
	                          FONT 'Arial' SIZE 09		;
	                          BACKCOLOR WHITE	;
	                          FONTCOLOR BLUE BOLD
If I change file i_label.ch that is way:

Code: Select all

=>;
   _DefineLabel (      ;
   <"name">  ;
for this way:

Code: Select all

=>;
   _DefineLabel (      ;
   <name>  ;
it work. So, only if i send the label definition by varieble. Is possible to change for to use the both situations?
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: How I can to send a varieble to LABEL?

Post by esgici »

Ola Jairo
Jairo Maia wrote:There are a way for me to send a variable in LABEL? ...
I guess this will run:

Label_Definition := "Label_Name"

@ 10,10 LABEL &Label_Definition ;
VALUE 'Name' ;
WIDTH 140 ;
HEIGHT 30 ;
FONT 'Arial' SIZE 09 ;
BACKCOLOR WHITE ;
FONTCOLOR BLUE BOLD

( Not tested :( but remembering something like this )

Regards
Viva INTERNATIONAL HMG :D
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: How I can to send a varieble to LABEL?

Post by Pablo César »

Desculpem cavalheiros, não sei se já resolveu com a indicação que colega Esgici fez. Mas eu não entendi direito, Jairo: você quer mudar o nome da label ? Ou deixar variável o conteúdo do label ?

--

Excuse me gentlemen, I do not know now if was solved with the indication from our colleague Esgici. But I did not get it right, Jairo, you want to change the label name ? Or to leave variable the label content ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Jairo Maia
Posts: 53
Joined: Sun Jul 17, 2011 1:47 pm
Location: Campinas - SP - Brazil

Re: How I can to send a varieble to LABEL?

Post by Jairo Maia »

Hello Esgici,
esgici wrote:I guess this will run:
Label_Definition := "Label_Name"
@ 10,10 LABEL &Label_Definition ;
I tried it, end I get the error: Sintax Error

Olá Pablo,
Pablo César wrote:você quer mudar o nome da label ? Ou deixar variável o conteúdo do label ?
I want to pass the Label definition by variable.

How I said above, I want to know if there are a way for change the file i_label.ch where I can pass the Label definition in both modes:

By Varieble:

Code: Select all

Label_Definition := "Label_Name"
@ 10,10 LABEL Label_Definition 
By Default mode:

Code: Select all

@ 10,10 LABEL Label_Name
Best Regards
User avatar
srvet_claudio
Posts: 2224
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: How I can to send a varieble to LABEL?

Post by srvet_claudio »

Jairo Maia wrote:Hello Esgici,

esgici wrote:
I guess this will run:
Label_Definition := "Label_Name"
@ 10,10 LABEL &Label_Definition ;

I tried it, end I get the error: Sintax Error
Hi Jairo.
Probably you defined the LABEL outside of the DEFINE WINDOWS adds PARENT Form_XX

Label_Definition := "Label_Name"
@ 10,10 LABEL &Label_Definition PARENT Form_XX VALUE 'Name' WIDTH 140 HEIGHT 30 FONT 'Arial' SIZE 09 BACKCOLOR WHITE FONTCOLOR BLUE BOLD

Best regards,
Claudio.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: How I can to send a varieble to LABEL?

Post by esgici »

Jairo Maia wrote:...I tried it, end I get the error: Sintax Error
Olá Jairo

I haven't any idea how you acquire this error :?

But this sample worked nice for me :

Code: Select all


#include <hmg.ch>

PROC Main()
   
   Label_Definition := "Label_Name"
   
   DEFINE WINDOW frmMILCName ;
      AT        0,0 ;
      WIDTH     400 ;
      HEIGHT    200 ;
      MAIN          ;
      TITLE     "Using macro substitution in Label Control Name"  
      
      ON KEY ESCAPE ACTION frmMILCName.Release

      @  10, 10 LABEL &Label_Definition ;
                VALUE 'Name'	 ;
                WIDTH 140	 ;
                HEIGHT 30	 ;
                FONT "Arial" SIZE 09 ;
                BACKCOLOR WHITE ;
                FONTCOLOR BLUE BOLD ;
                ACTION { || MsgBox( This.Name ) }

   END WINDOW
   
   frmMILCName.Center   
   frmMILCName.Activate
   
RETU // Main()
Using macro substitution in Label Control Name
Using macro substitution in Label Control Name
UMILCNAM.PNG (10.58 KiB) Viewed 3333 times
In addition in an old sample this macro substitution used for other controls too ( Caution : direct download link for .zip file )
Jairo Maia wrote:I want to pass the Label definition by variable.
Assumed you have intended "control name" with "Label definition". If you want mean another thing, please explain more precisely.

Regards
Viva INTERNATIONAL HMG :D
User avatar
Jairo Maia
Posts: 53
Joined: Sun Jul 17, 2011 1:47 pm
Location: Campinas - SP - Brazil

Re: How I can to send a varieble to LABEL?

Post by Jairo Maia »

esgici wrote:Olá Jairo
I haven't any idea how you acquire this error
But this sample worked nice for me :
Hello Esgici, you're right.

As you know, I am a beginner in HMG. So, in recent months I was studying and altering a series of tests in the SAMPLES folder and changing multiple files.

I do not know when and even where I changed something that detracted my work with HMG.

I did not can compile your example, so I decided to uninstall and reinstall my HMG.

Now everything is working properly.

Thanks to colleagues Pablo and Claudio for to have dedicated time to help me too.

Regards
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: How I can to send a varieble to LABEL?

Post by esgici »

Jairo Maia wrote:...Now everything is working properly.
Alright Jairo,

Happy HMG'ing :D
Viva INTERNATIONAL HMG :D
Post Reply