Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Morph saveOnFile
Last updated at 9:59 am UTC on 14 January 2019
The instance method #saveOnFile is implemented in class Morphic and allows any instance of Morph or a subclass to be saved in a file together with its submorphs.

The file extension is '.morph'.

Such a file may be dropped onto the desktop of a target image and will be reloaded there.

Implementation


The method uses a SmartRefStream to do the serialization.

First the method calls for all morphs

    prepareToBeSaved

After having obtained the file name the following method is called:

 Object

 saveOnFileNamed: filenameString
	"Save myself on a SmartRefStream file.  Writes out the version and class structure.  
        The file is fileIn-able.  UniClasses will be filed out."
	| fileStream |
	fileStream := FileStream newFileNamed: filenameString asFileName.
	fileStream fileOutClass: nil andObject: self.	"Puts UniClass definitions out anyway, and closes the stream."

Example

http://forum.world.st/Test-BackToTheFuture-morph-saved-from-Squeak-2-5-dropped-onto-a-desktop-of-a-Squeak6-0a-image-tt4940530.html


Note

If there are problems with loading the save morph file into an image with a higher update number it might be necessary to update a copy of an image first before saving the morph
See How to update a Squeak 5.1 image to the most recent trunk version