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:

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
.....
When I load this file, I do something like this:

VB Code:
  1. Select Case strKey
  2.                 Case "Opt_LengthOfCross"
  3.                     Opt_LengthOfCross = Val(strValue)
  4.                 Case "Opt_GeneralMarker_Color"
  5.                     Opt_GeneralMarker_Color = Val(strValue)
  6.                 Case "Opt_MeasurementMarker_Color"
  7.                     Opt_MeasurementMarker_Color = Val(strValue)
  8.                 .......
  9.  
  10.  
  11.                 Case "ShiftFactor_H(0)"
  12.                     ShiftFactor_H(0)  = Val(strValue)
  13.                 Case "ShiftFactor_H(1)"
  14.                     ShiftFactor_H(1)  = Val(strValue)
  15.                 Case "ShiftFactor_H(2)"
  16.                     ShiftFactor_H(2)  = Val(strValue)
  17.                 .......
  18.  
  19.             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.