Re: [NTLK] NS Question: how to access slot in parent frame

From: Laurent Daudelin (nemesys_at_cox.rr.com)
Date: Sun Mar 24 2002 - 09:08:54 EST


on 24/03/02 01:11, Jim Witte at jswitte_at_bloomington.in.us wrote:

> with the minutiae concerning viewBounds and whatnot removed. When I run
> it, it tells me that the variable 'base' is undefined in updateDisplay.
> Of course it is, it's not a variable. Then I chage
> base.currentDisplayNum to parent.currentDispalyNum, and it tells me
> "Object {class: <an immediate>, funcPtr: 7037727, numArgs: 0} is
> read-only / evt.ex.fr;type.ref.frame / -48214" Anyone have any idea
> what's going on here?

When you're accessing 'parent', this point to an object in ROM/package. So,
when you're trying to do something like base.currentDisplayNum := 0;, this
fails since you cannot modify ROM. Do you have this project as an NTK
project? There is a way to declare a variable in NTK. You can then create
relations between children to their parent. I'm guessing that this is what
doesn't work here. Even though you're declaring "base" for debug, I think
that's not enough to let the view access the base. BTW, don't forget that
parent, in this context, is the view containing your view. Then, once you
access your parent or your base, you would have to watch out and maybe
duplicate the parent's slot in order to modify it, since it's probably still
in ROM. Something like:

local currentDisplayNum := Clone(base.currentDisplayNum);
base.currentDisplayNum := currentDisplayNum;
base.currentDisplayNum := 0;

I think you could try something like that. I always used it with frames, but
in your example, it's a single variable, so I'm not completely sure it will
work. The idea is to duplicate that slot so that the duplicate lives in RAM.
Then, you have the object that owns this slot to point to this new
duplicate, since the original, don't forget it, lives in ROM or in a
package. Once your object points to the right duplicate in RAM, you can
change its value. Don't forget that in NewtonScript, you inhering only
what's *different* from your superclass...

-Laurent.

-- 
=====================================================================
Laurent Daudelin            <http://home.cox.rr.com/nemesys>
Logiciels Nemesys Software         mailto:nemesys_at_cox.rr.com

Brooks's Law prov.: "Adding manpower to a late software project makes it later" -- a result of the fact that the expected advantage from splitting development work among N programmers is O(N) (that is, proportional to N), but the complexity and communications cost associated with coordinating and then merging their work is O(N^2) (that is, proportional to the square of N). The quote is from Fred Brooks, a manager of IBM's OS/360 project and author of "The Mythical Man-Month" (Addison-Wesley, 1975, ISBN 0-201-00650-2), an excellent early book on software engineering.

-- Read the List FAQ/Etiquette: http://www.newtontalk.net/faq.html Read the Newton FAQ: http://www.guns-media.com/mirrors/newton/faq/ This is the NewtonTalk mailing list - http://www.newtontalk.net



This archive was generated by hypermail 2.1.2 : Tue Apr 02 2002 - 14:03:29 EST