I have created a small application to create output analog voltages. I am currently trying to implement code to load an "*.ini" file that simply has a list of values in it (one on each line). I have a LOAD_DEFAULTS button created in the uir file with the callback function LoadDefaults. The problem that happens is when I click the button when the application is running, the dialog box ends up appearing three times. So, I'll click the button, box opens, select file, hit Load, box opens, select file, hit Load, box opens, select file hit Load, values appear.
Also, when I hit the "Quit" button, the Load dialog box appears as well. The Quit Callback function has no reference to the LoadDefaults function.
The function is below and the only reference to LoadDefaults in the .uir or the .c file is for the button. Does anyone know what could be happening? Thanks.
Here's the code:
int CVICALLBACK LoadDefaults (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
if(EVENT_COMMIT)
{
int i;
if (FileSelectPopup ("", "*.ini", "*.ini", "Default File to Load",
VAL_LOAD_BUTTON, 0, 1, 1, 0, defaults_file_name) > 0)
{
FileToArray(defaults_file_name, default_settings, VAL_DOUBLE, 17, 1,
VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_ROWS, VAL_ASCII);
ramp_voltage_ch0 = default_settings[0];
SetCtrlAttribute( AO_PANEL, AO_PANEL_RAMP_VOLTAGE_CH0, ATTR_CTRL_VAL, ramp_voltage_ch0);
ramp_time_ch0 = default_settings[1];
SetCtrlAttribute( AO_PANEL, AO_PANEL_RAMP_TIME_CH0, ATTR_CTRL_VAL, ramp_time_ch0);
peak_time_ch0 = default_settings[2];
SetCtrlAttribute( AO_PANEL, AO_PANEL_PEAK_TIME_CH0, ATTR_CTRL_VAL, peak_time_ch0);
decay_time_ch0 = default_settings[3];
SetCtrlAttribute( AO_PANEL, AO_PANEL_DECAY_TIME_CH0, ATTR_CTRL_VAL, decay_time_ch0);
}
}
return 0;
}