![]() |
Telelogic TAU (steve huntington) | ![]() |
Topic Title: Accessing Childern of a parent class Topic Summary: Accessing Childern of a parent class Created On: 29-Jun-2006 22:10 Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
Hello
We have a parent class and we have declared a part children with multiplicity greater than 1. part children[*] Now the parent class needs to access the child for eg for (i =1; i<=NumChild; i++) children.status = newstatus; the problem is that no matter what the value of i is, this only allows us to access only the first instance and therefore chnage only the status of the first children[1] Any pointers will be a big help to us. Thanks |
|
![]() |
|
![]() |
|
The container of the association is a String by default. So new instances must be appended to it and then you iterate over it. Something like:
------------------------- Greg Gorman Vice President, Product Management Modeling and Test Products Telelogic AB |
|
![]() |
|
![]() |
|
Creating a child:
Child newChild; newChild = new Child(); children.append(newChild); return newChild; Accessing data assuming we have an Operation called updateStatus(myChild:Child, newStatus: String) myChild.status = newStatus; Printing all of the children's status displayStatus() for (Integer i = length(children); i > 0; i=i-1) { String myChildStatus = children[ i].status; [[printf("%s\n", #(myChildStatus));]] } Let me know if this gets you in the right direction. Greg ------------------------- Greg Gorman Vice President, Product Management Modeling and Test Products Telelogic AB Edited: 7-Jul-2006 at 19:39 by Greg Gorman |
|
![]() |
Telelogic TAU
» TAU/Developer
»
Accessing Childern of a parent class
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.