Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!ut-emx!emx.utexas.edu From: sukumar@emx.utexas.edu (Sukumar Rathnam) Newsgroups: comp.lang.smalltalk Subject: saving and recovering variables Message-ID: <36951@ut-emx> Date: 6 Sep 90 18:38:39 GMT Sender: sukumar@ut-emx Organization: The University of Texas at Austin; Austin, Texas Lines: 39 The following is hack that shows you how to save an object instance on to afile the instance can be resrtored by using the class message fooRestore to class FOO !FOO methods ! saveObject:fooObj "this experimental bit of code saves an object instance on a file so that it can be restored later. author: sukumar 8/27/90" | tmp tmp1 objectSize allObj| tmp := fooObj storeString. tmp at:1 put:$ . objectSize := tmp size. tmp at:objectSize put: $ . tmp1 := Disk newFile: (File fileName: 'foo' extension: (String with: $l with: $s with: $t)). tmp1 lineDelimiter: 13 asCharacter. tmp1 nextPutAll:'!!FOO class methods !!';cr. tmp1 nextPutAll:'fooRestore';cr. tmp1 nextPutAll: '|tmp|';cr. tmp1 nextPutAll: 'tmp := '. tmp1 nextPutAll: tmp. tmp1 nextPutAll: '.';cr. tmp1 nextPutAll: '^tmp'. tmp1 nextPutAll: '!! !!'. tmp1 close.! !