Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - save save memory variables to disk http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 save                Save memory variables to disk
------------------------------------------------------------------------------
 Syntax
   save variables to cFile [additive]

 Arguments
   variables is a list of variables.
   cFile is the name of the file where values are to be stored.

 Description
   The save command saves the contents of memory variables to disk.
   The format of Force's variable save files is not compatible with the dBase
   .mem files.

   save creates a disk file with the name cFile unless additive is
   specified. If the variable exists in the file, its original value is
   replaced.

   Arrays may be saved and restored by using the syntax aArrayName[],
   i. e., do not specify an array element. The entire array is saved and
   restored. Be sure the number of elements restored is the same as the
   number saved.

   Field variables may not be saved. To save the screen, use the
   savescreen() procedure or the savescrn() function.

 Example
   #define EXAMPLE_SYSTEM
   #include example.hdr

   typedef struct DATASTRUCT
      char( 20 ) cName
      char( 15 ) cCity
   enddef
   
   proc Test_save
   vardef
      char( 15 ) cName
      byte       aBytes[ 200 ]
      DATASTRUCT sData
   enddef
   cName         := "Jennifer"
   aBytes[ 152 ] := 'X'
   sData.cName   := "Bettine"
   sData.cCity   := "L. A."
   save __syscolor[], cName to "test.cfg"
   save sData, aBytes[] to "test.cfg" additive
   ? cName, chr( aBytes[ 152 ] ), sData.cName, sData.cCity
   cName         := "John"
   aBytes[ 152 ] := 'Y'
   sData.cName   := "Thomas"
   sData.cCity   := "Frisco"
   __syscolor[ CLR_STD ] := BLUE_CYAN
   ? cName, chr( aBytes[ 152 ] ), sData.cName, sData.cCity
   restore aBytes[], __syscolor[] from "test.cfg"
   restore cName, sData from "test.cfg"
   ? cName, chr( aBytes[ 152 ] ), sData.cName, sData.cCity
   erase "test.cfg"
   endproc

   proc main
   Test_save()
   endproc

See Also: restore

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson