Program SAVESET.PRG illustrates how to save all of the FoxPro 2.5 environmental settings and system memvars. You call SAVESET.PRG at the beginning of your program system.
Program SETNAMES.PRG initializes an array of SET keywords. To speed up processing, SAVESET.PRG only calls SETNAMES.PRG the first time it is called. SETNAMES.PRG saves its arrays in a memvar file (SETNAMES.MEM). From then on, SAVESET.PRG restores the arrays from the memvar file instead of calling SETNAMES.PRG.
In the SETNAMES.PRG programs arrays are initialized. The array Set_OnOff is initialized with the names of keyword following the SET command verb for commands that turn ON and OFF an environmental option. The array Set_Values is initialized with name of keywords associated with SET commands for environmental parameters with a value other than ON and OFF. After the arrays are initialized, they are saved in a memvar file named SETNAMES.MEM using the SAVE command.
You can change any of the environment setting any way you like and right before your program exits, your program can call RESTSET.PRG to restore the environmental settings and system memvars.
Program RESTSET.PRG restores the original environmental settings and system memvars. First it reads the system Save_Set array from the SAVESETS.MEM memvar file. Then it reestablishes the original environment.