Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

RESTORE FROM, SAVE TO

Allows the storage and retrieval of a series of memory variables to either a memo field or a file. Seems like a good idea, but has some limitations.

Usage

SAVE [ ALL LIKE VarSkeleton | ALL EXCEPT VarSkeleton ]
        TO FileName | MEMO MemoField
RESTORE FROM FileName | MEMO MemoField [ ADDITIVE ]

SAVE and RESTORE allow specified memory variables to be stored into a memo field or a MEM file (the default extension, which can be overridden). This can be used to store a series of state variables or settings that can be restored at will. However, a few limitations apply. First, all variables are restored with private scope, regardless of their initial scope. Secondly, failure to use the ADDITIVE keyword results in the obliteration of all variables in memory.

The worst limitation we see, though, is that MEM files are difficult to read. The files and memo fields are stored in a binary format, which is a pain in the neck (though possible) to parse. Fixing a broken MEM file is not for the weak of heart. In addition, it can be really difficult to troubleshoot a problem where a MEM file clobbers existing variables.

We prefer to either store our settings to a DBF with predefined fields for each setting or use an INI file or the Registry to store free-form settings.

Example

SAVE TO MYARRAYS.MEM ALL LIKE LA*
RESTORE FROM MYARRAYS ADDITIVE

See Also

INI Files, Registration Database