Problems with Restore [message #47868] |
Wed, 08 March 2006 11:07  |
vcarlos
Messages: 21 Registered: February 2006
|
Junior Member |
|
|
Hi all,
I am writing a class that I want add save and restore features to it.
My class is defined something like this:
<code>
pro OperatorLanguageMapping__define;
objectClass = $
{OperatorLanguageMapping, $
password : '', $ ; holds the password
name : '', $ ; holds the operator name
language : '' $; holds the language
}
end
OperatorLanguageMapping::Restore, fileName
restore, fileName, RESTORED_OBJECTS = temp
self.name = temp->GetName()
self.language = temp->GetLanguage()
self.password = temp->GetPassword()
end
OperatorLanguageMapping::Save, fileName
save, self, fileName
end
</code>
Obviously, the class has its getter and setter methods.
The problem is that when I do this:
<code>
o1 = obj_new("OperatorLanguageMapping")
o1->SetPassword, '123456'
o1->Save, '~/o1.sav'
o1->SetPassword, 'test'
o1->Restore, '~/o1.sav'
print, o1->GetPassword
</code>
What I got is: 'test' instead of '123456'
I tried to debug the software changing the method restore to look like
this:
<code>
OperatorLanguageMapping::Restore, fileName
restore, fileName, RESTORED_OBJECTS = temp
self.password = 'password'
print, self->GetPassword()
end
</code>
By now what I got is :
password
test
That is, after exiting the restore method of the object, the changes I
have made inside are not available outside the method(!!).
I keep trying to find out what was happening, and when I comment out
the line that call the restore procedure inside the Restore method of
the Class OperatorLanguageMapping, then, what I got was:
password
password
That is, changing the attribute inside the method restore worked.
I don't know if I was clear, my english is not that good and the
problem is not easy to explain too...
Does anyone have an idea of what could be wrong?
I have also tried to use IDL_SaveFile object, but the result was the
same...
Thanks all
Vinicius
|
|
|