LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Numbers from Array to Panel

Hello,

I'm new in labWindows. I don't know how to show every values from array in Panel. I always get only one number. Im sorry for my ugly code. Please, help me. Smiley Happy

 

int CVICALLBACK binary (int panel, int control, int event,
						void *callbackData, int eventData1, int eventData2)
{ switch (event)
	{
		case EVENT_COMMIT:
			GetCtrlVal(panelHandle,PANEL_wynik,tablica3);
			sscanf(tablica3, "%d", &t);
			int i=0;
			while(t) 
			{
				tabInt[i++]=t%2;
				t=t/2;
			}
			for(int j=i-1; j>=0; j--)
			{
				g =	tabInt[j];
				sprintf(tablica3, "%ld", g);
			}
			SetCtrlVal(panelHandle, PANEL_wynik, tablica3);
			break;
	}
	return 0;
}

 

0 Kudos
Message 1 of 2
(2,321 Views)

First of all, if you only want to display an integer number in binary format you can use the appropriate format show in the numeric control, as you can see here (this is not available for floating point numbers):

 

Screenshot 2018-10-21 13.23.25.png

 

If you want to create it programmatically instead, the problem in your code is that your sprintf instruction every time replaces the existing content of the string with the new one. Try with this code instead:

sprintf (tablica3, "%s%ld", tablica3, g);

 

Finally, a simple search in the forum would have returned you a list of discussions with already solved similar questions to start with to solve your problem.



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 2
(2,281 Views)