Hi, all,
I need to write functions that can save all the user settings variables as well as some variables that are to trace the progress of user's action into a file. And the user can restore the progress and settings by loading that file. Simply speaking, it is just like the save and load function in a computer game program.
What I did is to save all the variable namesand their values into text file by a series of Print commands. The text file looks like this:
When I load this file, I do something like this:Code:Opt_LengthOfCross = 5 Opt_GeneralMarker_Color = 16777215 Opt_MeasurementMarker_Color = 16711808 Opt_ScaleMarker_Color = 255 Opt_ManualMarker_Color = 8388863 Opt_Scan_ColorThreshold = 3000000 Opt_ProfileMarker_Color = 16776960 Opt_Threshold_Sample_Size = 29 Opt_Threshold_HalfRange = 25 Opt_Align_Scan_Length_MM = 40 ShiftFactor_H(0) = 12 ShiftFactor_H(1) = 11 ShiftFactor_H(2) = 12 ShiftFactor_H(3) = 12 ShiftFactor_V(0) = 2 ShiftFactor_V(1) = 5 ShiftFactor_V(2) = 1 ShiftFactor_V(3) = 3 .....
VB Code:
Select Case strKey Case "Opt_LengthOfCross" Opt_LengthOfCross = Val(strValue) Case "Opt_GeneralMarker_Color" Opt_GeneralMarker_Color = Val(strValue) Case "Opt_MeasurementMarker_Color" Opt_MeasurementMarker_Color = Val(strValue) ....... Case "ShiftFactor_H(0)" ShiftFactor_H(0) = Val(strValue) Case "ShiftFactor_H(1)" ShiftFactor_H(1) = Val(strValue) Case "ShiftFactor_H(2)" ShiftFactor_H(2) = Val(strValue) ....... End Select
My problem is, the number of variables is much larger than I expected: almost 50 variables, and some of them are array of size >100. It is inpractical to handle the save/load function in this way.
Do anyone have a clue for it?![]()
Some of the variables are just native data type, but some are user-defined type, and some are array. Also the variable names cannot be unified because the are used in different modules and for different purposes.




Reply With Quote