Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic TAU (steve huntington)
Decrease font size
Increase font size
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
Search Topic Search Topic
Topic Tools Topic Tools
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 29-Jun-2006 22:10
User is offline View Users Profile Print this message


Smriti Kansal

Posts: 1
Joined: 29-Jun-2006

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
Report this to a Moderator Report this to a Moderator
 7-Jul-2006 18:09
User is offline View Users Profile Print this message


Greg Gorman

Posts: 75
Joined: 4-Oct-2002

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
Report this to a Moderator Report this to a Moderator
 7-Jul-2006 19:05
User is offline View Users Profile Print this message


Greg Gorman

Posts: 75
Joined: 4-Oct-2002

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
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic TAU forum.
There are currently 1 users logged in.
The most users ever online was 15 on 31-Mar-2008 at 16:22.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.