LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Button and If()

Solved!
Go to solution

Good day,

do you know how to modify the if () condition when I press a button to execute it?

 

if(EVENT_COMMIT == CallbackProtokolSklon)
	 {	 
	 WordRpt_GoToCell (tableHandle,1, 3); 
	 WordRpt_SetTextAttribute (g_docHandle, WR_ATTR_FONT_BOLD,WRConst_TRUE);
	 WordRpt_SetTextAttribute (g_docHandle, WR_ATTR_FONT_UNDERLINE,WRConst_UnderlineNone);
	 WordRpt_SetTextAttribute (g_docHandle, WR_ATTR_FONT_NAME, "Times New Roman");
	 WordRpt_SetTextAttribute (g_docHandle, WR_ATTR_FONT_SIZE, 9.0);
	 WordRpt_SetTextAttribute (g_docHandle, WR_ATTR_TEXT_ALIGN,WRConst_AlignLeft);
	 WordRpt_WriteToCell (tableHandle, 1, 3, "Mezní sklon [‰]: "); 
	 }
I write the word about 6 buttons anyway, but I need to say one more thing after pressing one button.
It must remain in the one method, I do not want to call it via the button function.

not sure how to do this?
provedla.jpg
Thank you
0 Kudos
Message 1 of 8
(4,711 Views)

I must admit that I don't understand your question! Can you clarify it better?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 8
(4,693 Views)
I am sorry for my English.
If I press the "gradient" button, I want the condition to be executed.
I don't know how to make this condition entry.
 
 
0 Kudos
Message 3 of 8
(4,686 Views)

Sorry, I didn't focused on the code. The correct code for a control callback is:

int CVICALLBACK CallbackProtokolSklon (int panel, int control, int event,
    void *callbackData, int eventData1, int eventData2)
{
   if (event == EVENT_COMMIT)
   {
       // Your code here
   }
   return 0;
}

 

where 'event' is a parameter of the callback itself.

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 8
(4,680 Views)
Solution
Accepted by topic author MajklS

Thank you for answer

 

As I wrote, I didn't want to put it in the function of calling.


I solved it differently

 

 if(vypisSklonu==1)
	 {
	 WordRpt_GoToCell (tableHandle,1, 3); 
	 WordRpt_SetTextAttribute (g_docHandle, WR_ATTR_FONT_BOLD, WRConst_TRUE);
	 WordRpt_SetTextAttribute (g_docHandle, WR_ATTR_FONT_UNDERLINE,WRConst_UnderlineNone);
	 WordRpt_SetTextAttribute (g_docHandle, WR_ATTR_FONT_NAME, "Times New Roman");
	 WordRpt_SetTextAttribute (g_docHandle, WR_ATTR_FONT_SIZE, 9.0);
	 WordRpt_SetTextAttribute (g_docHandle, WR_ATTR_TEXT_ALIGN,WRConst_AlignLeft);
	 switch(Jazyk){
	 case 0:
	 Fmt(buffer,"                            Mezní sklon:  %f [‰]",mezSklon);
	 break;
	 case 1:
	 Fmt(buffer,"                            nevim:  %f [‰]",mezSklon);
	 break;

	 break;
	 }
Still thank you for your help 🙂
0 Kudos
Message 5 of 8
(4,632 Views)

Glad to know you solved your problem. Just out of curiosity, where is this code placed? In a control callback or is this a standalone routine?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 8
(4,628 Views)

I defined a global variable "vypisSklonu".

If you press the "Gradient" button, the value of the variable will be 1. and the condition is executed if(vypisSklonu==1)

So I can use a variable in any source code.
int CVICALLBACK CallbackProtokolSklon (int panel, int control, int event,
									   void *callbackData, int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_COMMIT:
		vypisSklonu=1;	
		
			if (Jazyk == 0)
		{
		 protokolSklon();  
		}
		
			if (Jazyk == 1)
		{
		 protokolSklon(); 
		}
		
			if (Jazyk == 2)
		{
		 protokolSklon2(); 
		}
			break;
	}

	return 0;
}

 

0 Kudos
Message 7 of 8
(4,625 Views)

This is not what I asked. Those lines that call WordRpt functions where are located?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 8 of 8
(4,613 Views)