Microsoft KB Archive/97637

= Using Memory Variable Files (.MEM) in FoxPro =

Article ID: 97637

Article Last Modified on 12/3/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft FoxPro 2.0
 * Microsoft FoxPro 2.6 for MS-DOS
 * Microsoft FoxPro 2.6a Standard Edition
 * Microsoft FoxPro 2.6 Standard Edition
 * Microsoft FoxPro 2.6a Standard Edition
 * Microsoft FoxPro 2.6a Professional Edition for Macintosh
 * Microsoft FoxPro 2.6 for SCO/UNIX

-



This article was previously published under Q97637



SUMMARY
Memory variable files are a way to store the status of memory variables that are currently stored in memory and use them later in the same program or in another session of FoxPro.

The commands used when creating and using .MEM files are as follows: SAVE TO |TO MEMO [ALL LIKE|ALL EXCEPT ]

and

RESTORE FROM |FROM MEMO [ADDITIVE]



MORE INFORMATION
A few things that are important to remember when using memory variable files:

  All memory variables that are stored in the .MEM file, regardless of being declared PUBLIC or PRIVATE, are treated as PRIVATE variables if they are restored in a program unless the ADDITIVE clause is added to the RESTORE FROM command. They are treated as PUBLIC variables if they are restored from the Command window.

Following is an example of using the RESTORE FROM....ADDITIVE clause to declare a restored memory variable as PUBLIC in a program: PROG1.PRG

val1 = 12 val2 = &quot;test&quot; SAVE TO temp

PROG2.PRG

PUBLIC val2 RESTORE FROM temp DISPLAY MEMORY LIKE val? CLEAR ALL PUBLIC val2 RESTORE FROM temp ADDITIVE DISPLAY MEMORY LIKE val?   All variables currently in memory will be placed in the .MEM file unless the ALL EXCEPT or ALL LIKE options are included with the SAVE TO command. The wildcard characters ? and * can be used with these options.

To exclude variables, use the ALL EXCEPT option of the SAVE TO command. For example: SAVE TO test ALL EXCEPT v* To include variables, use the ALL LIKE option of the SAVE TO command. For example: SAVE TO test ALL LIKE var?  System memory variables are not affected by RESTORE FROM or SAVE TO commands. Any memory variables or arrays currently in memory are erased unless the ADDITIVE clause is included with the RESTORE FROM command. If a variable brought in has the same name as an existing variable, the value of the variable in the memory file will replace the current value. If the number of variables that will be brought in by the RESTORE FROM ADDITIVE command exceeds the MVCOUNT limit when added to the variables currently in memory, the maximum number possible will be restored. The MVCOUNT setting is stored in the CONFIG.FP file with the default setting of 256 variables.

Additional query words: VFoxWin FoxUnix FoxMac FoxDos FoxWin 2.50 2.50a 2.50b 2.50c x- platform cross-platform

Keywords: KB97637

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.