07-22-2010 09:00 AM
Hi,
Does anyone know of a straightforward way to save to file and read from file screen layouts which are not UIR files? FileToArray and ArrayToFile do not suffice as they store arrays of only simple types, not structs.
Thanks,
Gayle
Solved! Go to Solution.
07-22-2010 09:18 AM
I do not exactly understand you reference between "screen layouts" and "array of structures", but anyway, if you have an array of structures you can save it to disk by using this code.
// Structure definition
typedef struct {
// Structure fields definition
} myStructure;
// Dynamic structure allocation
s = calloc (numOfElements, sizeof (myStructure)));
// Struct saving
{
char msg[512];
FILE *stH = NULL;
fH = fopen ("myfile.dat", "rb+");
if (errno) goto Error;
fwrite ((char *)&s, sizeof(myStructure), numOfElements, fH);
if (errno) goto Error;
Error:
if (errno) {
strcpy (msg, "General I/O error found.");
}
if (fH) fclose (fH);
}
07-22-2010 09:42 AM
Thank you. Your solution will work well. I'm using an array of structures to store information about the widgets the user placed on the screen, such as the location, foreground and background colors, etc.
- Gayle
07-26-2010 03:08 AM
Hi Gayle,
Have you seen the SavePanelState / RecallPanelState function pair?
These may be the functions you are looking for.
Regards,
07-26-2010 07:56 AM
I have, and I've tried them. They don't place any of the controls on the screen that I had created. I contacted NI about this, sent them my code with SavePanelState and RecallPanelState, and they said that these functions save and restore the values in the controls but not their placement on the screen, font size, etc. If these functions do save and restore the layouts of the widgets on the screen, etc., as well, please let me know. Thanks.
- Gayle