04-03-2008 10:26 AM
04-03-2008 01:13 PM
04-03-2008 01:17 PM
04-03-2008 03:51 PM
A ring is a control that holds two elements for each item: a label (which is always a string) and a "value" of a type defined by the user (char *, int, double...) The default data type for a ring control is integer, so unless you have modified it while creating the label/value list (it's the first parameter on top of that panel) GetCtrlVal expects a variable of type int (well, actually a pointer to...).
Looking at the error returned, it seems that the ring control still has its default integer data type: that's why you get the error while passing a string. But are you sure you want the value back and not the label? You are treating the return value as a string, so it seems to me that you expect to have the label back...
A possible solution to operate on ring values instead of labels could be like this:
A) Create the list of items keeping the default int data type and adding elements like these:
Label Value
"Impedance" 0
"Resistance" 1
"SelfResonatingFrequency" 2
B) Get the ring value and operate accordingly:
int testTypeVal;
GetCtrlVal(ADDTEST, ADDTEST_TESTTYPE, &TestTypeVal);
switch (TestTypeVal) {
case 0: // Impedance
x = 1;
while (x <=NUMIMPFORCEDELEMENTS)
{
CVIXMLNewElement(parent, -1, ImpFields[x-1], &child);
CVIXMLSetElementValue(child, ImpDefaults[x-1]);
CVIXMLDiscardElement(child);
}
break;
case 1: // Resistance
// Your code here
break;
case 2: // Self Resonating Frequency
// Your code here
break;
default: // Unknown value ?
// Your code here
break;
}
There can be another reason for the error you are receiving. It seems strange to me that a panel handle has the same name of the panel itself (in this case ADDTEST😞 it is possible that you are passing an incorrect variable to GetCtrlVal as the panel handle, so the program is actually operating on a panel and control different from the one you want, with different associated data type, from which the error.
04-03-2008 03:57 PM
04-03-2008 04:03 PM
04-03-2008 04:05 PM