From: Mark M. <mie...@gm...> - 2012-12-28 00:45:52
|
On Thu, Dec 27, 2012 at 3:50 PM, Art Heimsoth <art...@ar...> wrote: > I am trying to use a Data Class to pass data between a mother > and child dialog, where the ::attribute contains a stem variable. > I have not found how to do this, but if I put a non-stem > variable in the statements, it seems to work - so I think I have > the dialogs, methods, class and attribute statements correct. It will work, although if you are having problems using a stem variable, I would consider using some other type of object than a stem. Use a Directory object in place of a stem. But, if you are determined to use a stem you probably need to do something like this: ::class Parent class ::method dataPassingMethod data.value1 = 14 data.value2 = 'Tom' obj = .MyClass~new(...) obj~data = data. ::class MyClass ::attribute data ::method someMethod stm. = self~data say 'Name is:' stm.value2 say 'Number is:' stm.value1 The above will let you use a stem the way you are probably used to using a stem. Of course you could always use the [] syntax to access the stem, something like: ::class Parent class ::method dataPassingMethod data.value1 = 14 data.value2 = 'Tom' obj = .MyClass~new(...) obj~data = data. ::class MyClass ::attribute data ::method someMethod name = self~data[value2] age = self~data[value1] Recall that when you use the [] to access the tails, it is case sensitive. So I purposefully did not quote the value1 or value2. > A second part of this is, can I somehow use methods that are > located in the mother dialog, from the child dialog? If they are public methods you can. > I would > like to keep from replicating several of the common methods > that are already in use in the mother dialog, from having to > duplicate the code in the children dialogs. Using a variation of my above code: ::class Parent class ::method printSecret expose secret say secret ::method dataPassingMethod data. = <set up your data in the stem> obj = .MyClass~new(...) obj~data = data. obj~parent = self ::class MyClass ::attribute data ::attribute parent ::method someMethod stm. = self~data self~parent~printSecret > If so, are the > exposed variables in the mother dialogs then from the mother > variable pool or from the child's pool? Does this make sense? What you want to do makes sense. If you have a reference to any object, you can invoke methods in that object as long as they are public. If you make a reference to the parent dialog available to the child dialog, then the child can invoke any public method in the parent. The variable pool part of the question probably indicates a little confusion on your part. The exposed variables in the parent dialog are only available in the parent, and the same thing in the child. But when you invoke a method in the parent, that method will be running in the context of the parent, so the method has access to its exposed variables. It doesn't have access to any exposed methods in the child. -- Mark Miesfeld |