Writing/Reading a Structure to Flash Memory
Greetings,
I would like to save the values of 100 instances of a structure to flash for reloading at startup. The structure is created in a module and cannot be peristent.
If someone could give me a quick explantion on this, it would be much appreciated.
Thank you.
I would like to save the values of 100 instances of a structure to flash for reloading at startup. The structure is created in a module and cannot be peristent.
DEFINE_TYPE
Structure MyStruck
{
//There are ten various variable types in the structure
}
DEFINE_VARAIBLE
MyStruck MyStructure[100]
If someone could give me a quick explantion on this, it would be much appreciated.
Thank you.
0
Comments
Another method that would work in a similar way is to write the variable into a text file in the master's virt disk. You'd have to write some kind of translator to move the data on and off the disk.
I do this with my very large Cablevision/Satellite TV channels listing.
DEFINE_VARIABLE LONG lPos SLONG slReturn SLONG slFile SLONG slResult CHAR sXMLString[50000] DEFINE_FUNCTION fnSAVE_YOUR_STRUCT_NAME() { // Convert To XML lPos = 1 slReturn = VARIABLE_TO_XML(YOUR_STRUCT_NAME, sXMLString, lPos, 0) // Save Structure To Disk ? XML slFile = FILE_OPEN('YOUR_STRUCT_NAME.xml', 2) slReturn = FILE_WRITE(slFile, sXMLString, LENGTH_STRING(sXMLString)) slReturn = FILE_CLOSE(slFile) } DEFINE_FUNCTION fnRELOAD_YOUR_STRUCT_NAME() { // Read XML File slFile = FILE_OPEN('YOUR_STRUCT_NAME.xml',1) slResult = FILE_READ(slFile, sXMLString, MAX_LENGTH_STRING(sXMLString)) slResult = FILE_CLOSE (slFile) // Convert To XML lPos = 1 slReturn = XML_TO_VARIABLE (YOUR_STRUCT_NAME, sXMLString, lPos, 0) }This will do the trick!