Re: Problems with Restore [message #47990 is a reply to message #47868] |
Thu, 09 March 2006 01:02  |
Antonio Santiago
Messages: 201 Registered: February 2004
|
Senior Member |
|
|
Here is a partial response of your (our) problem, when you restoring the
file, both 'self' and 'temp' references are the same, that is the 'self'
reference changes.
------ Object code test --------
FUNCTION OperatorLanguageMapping::Init
RETURN, 1
END
PRO OperatorLanguageMapping::Restore, fileName
print, 'Restoring'
print, 'Before:'
help, self ;; <----- Here is a reference
restore, fileName, RESTORED_OBJECTS = temp
print, 'After:'
help, self, temp[0] ;; <----- Here 'self' reference has changed
self.password = temp[0]->GetPassword()
END
PRO OperatorLanguageMapping::Save, fileName
save, self, FILENAME=fileName
END
PRO OperatorLanguageMapping::SetPassword, pass
self.password = pass
END
FUNCTION OperatorLanguageMapping::GetPassword
RETURN, self.password
END
PRO OperatorLanguageMapping__define;
objectClass = { OperatorLanguageMapping, $
password : '' $ ; holds the password
}
END
------ Object code test --------
------ Test program --------
PRO optest
o1 = obj_new("OperatorLanguageMapping")
o1->SetPassword, '123456'
o1->Save, '~/o1.sav'
o1->SetPassword, 'test'
o1->Restore, '~/o1.sav'
print, o1->GetPassword()
END
------ Test program --------
A possible solution maybe store the 'self' reference into a variable and
after restoring the file reassign it:
PRO OperatorLanguageMapping::Restore, fileName
print, 'Restoring'
print, 'Before:'
help, self
a=self ;; <--- Store 'self' reference'
self=0 ;; <--- Changue it to a scaler, if not, a=self=temp.
restore, fileName, RESTORED_OBJECTS = temp
print, 'After:'
help, self, temp[0]
self=a ;; <---- Re-assing the initial reference.
self.password = temp[0]->GetPassword()
END
Bye.
--
-----------------------------------------------------
Antonio Santiago P�rez
( email: santiago<<at>>grahi.upc.edu )
( www: http://www.grahi.upc.edu/santiago )
( www: http://asantiago.blogsite.org )
-----------------------------------------------------
GRAHI - Grup de Recerca Aplicada en Hidrometeorologia
Universitat Polit�cnica de Catalunya
-----------------------------------------------------
|
|
|