Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Morph class fromFileName:
Last updated at 5:08 am UTC on 4 February 2019
How to load a *.morph file


 Morph fromFileName: 'yourfile.morph'

Implementation

fromFileName: fullName
"Reconstitute a Morph from the file, presumed to be represent a Morph saved
via the SmartRefStream mechanism, and open it in an appropriate Morphic world"

 	| aFileStream morphOrList |
	aFileStream := (MultiByteBinaryOrTextStream 
                        with: ((FileStreamreadOnlyFileNamed: fullName) binary contentsOfEntireFile)) binary reset.
	morphOrList := aFileStream fileInObjectAndCode.
	(morphOrList isKindOf: SqueakPage) ifTrue: [morphOrList := morphOrList contentsMorph].
	Smalltalk isMorphic
		ifTrue: [ActiveWorld addMorphsAndModel: morphOrList]
		ifFalse:
			[morphOrList isMorph ifFalse: [self inform: 'Can only load a single morph
 into an mvc project via this mechanism.'].
			morphOrList openInWorld]