LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Using EasyTab functions

Hi,

I am using CVI Ver6.0.

I have an application that creates a main panel with a Tab control created using the EasyTab functions.
Most of the information about the application is defined in a file and therefore each of the Tab Panel are created dynamically such as;

for(n=.........)
{
tab_panel[n] = NewPanel(main_panel, ......);

....
}

I then add the tab panels using

switch(numOfPanels)
{
case ONE_PANEL:
EasyTab_AddPanels(main_panel, tabCtrl, ONE_ROW, tab_panel[0], 0); // add one panel
break;

case TWO_PANEL:
EasyTab_AddPanels(main_panel, tabCtrl, ONE_ROW, tab_panel[0], tab_panel[1], 0); // add two panels
break;

......//add more panels
}


At the moment my switch statement limits the number of tabs added.

Is there a way to make the statement EasyTab_AddPanels(main_panel, tabCtrl, ONE_ROW, ....) my dynamic so that I can get rid of the switch statement.

Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 1 of 3
(3,529 Views)
Hi Ray,

you could design a variable params functions using va_start, va_arg and va_end macros.

Your function could be as follows (it's pseudo-code, so you'll have to debug a little):

int AddingPanels (int *panels)
{
int myPanel, error = 0;

// Initializa variable-params
va_start (ap, panels);

// Add your panels
myPanel = va_arg(panels, int);
while (myPanel > 0)
{
errChk( EasyTab_AddPanels (panel, easyTabCtrl, row, myPanel, 0));
sheetPanel = va_arg(panels, int);
}

Error:
// End variable-parms
va_end (panels);

return error;
}


The calling function (assuming you want to load 3 panels):

{
// Load the panels in memory

panels[0] = handle0;
panels[1] = handle1;
panels[2] = handle2;
panels[3] = 0;
AddingPanels (panels);

// ...
}



Hope this helps
Roberto


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?
Message 2 of 3
(3,515 Views)
Hi Roberto,

>>you could design a variable params functions using va_start, va_arg and va_end macros

I did think about using this, but for some reason I had in mind that you had to add all the panels at one go.

Now that thought has been erased and I can do repeated calls of
EasyTab_AddPanels (panel, easyTabCtrl, row, myPanel, 0);

I have used a simple for loop and everything works a treat.

Thanks for the help
Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 3 of 3
(3,494 Views)