LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Label/Value pairs and SavePanelState command.

Hi,
I would like to import Label/Value pairs into my similar controls at each run of the program. This is because the list may change periodically and instead of having to change each control seperately, I can just change a text file and all would be changed. However, I am using SavePanelState and it replaces what I import. My code looks like this:
vars1file = OpenFile ("d:\\ctds2\\ringvars1.txt", VAL_READ_ONLY,
VAL_OPEN_AS_IS, VAL_ASCII);

for(x=0; x<200; x++)
ReadLine (vars1file, variables[x], 30);

CloseFile (vars1file);

for (y=0; y<20; y++){

ClearListCtrl (ser1panel, SER1PANEL_SER1_1 + y);
ClearListCtrl (ser2panel, SER2PANEL_SER1_1 + y);

for (x=0; x<
200; x++)
{
Fmt(varvalue, "%s<%s%i", "value", x);
InsertListItem (ser1panel, SER1PANEL_SER1_1 + y, -1, variables[x],
varvalue);
InsertListItem (ser2panel, SER2PANEL_SER1_1 + y, -1, variables[x],
varvalue);
}
}
/* Recall previous panel states here */

RecallPanelState (ser2panel, "d:\\CTDS2\\pnlstate.pnl", 3);
RecallPanelState (ser1panel, "d:\\CTDS2\\pnlstate.pnl", 4);

Any Ideas??
0 Kudos
Message 1 of 5
(3,143 Views)
It sounds like you don't understand the functionality of SavePanelState and RecallPanelState. These two functions are for exporting and importing to file EVERY detail of your panel's current state including format, color, position, values, etc. everything! This includes the label/value pairs of your lists. So, you are filling in the lists, then overwriting them from the previous state saved in pnlstate.pnl. What you want to do is either resave the panel state after you have filled in the lists, or recall the panel state before filling the lists.

Best Regards,

Chris Matthews
Measurement Studio Support Manager
0 Kudos
Message 2 of 5
(3,143 Views)
I tried recalling the panel state before filling in from the list. What happens then is very bizarre. My label/value pairs get duplicated and inverted. I end up with two lists exactly in opposite order?? If I try and save them again, I get three.
0 Kudos
Message 3 of 5
(3,143 Views)
You should do the RecallPanelState BEFORE the ClearListCtrl also. That way you will clear out any list items loading from the pnl file before filling the list.

Chris
0 Kudos
Message 4 of 5
(3,143 Views)
Thanks Chris. I was trying to do it all at once. I will make a maintenance panel to feed the list when needed. That way I can update all the controls periodically and not disrupt them everytime.
0 Kudos
Message 5 of 5
(3,143 Views)