QotD    "To be or not to be" – Shakespeare
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Morph class fromFileName:
Last updated at 9:01 am UTC on 30 March 2017
How to load a *.morph file

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