Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Alternative to 'for <thing> in <thingSet> do??
Topic Summary:
Created On: 16-Dec-2003 14:45
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
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.
 16-Dec-2003 14:45
User is offline View Users Profile Print this message


Robin Riley

Posts: 4
Joined: 15-Aug-2003

Hi,

Is there not a way to access collection items (e.g. objects in a module, history records in an object, etc) other than using the for-in-do loop?? This method seems highly inefficient. What if you want to loop in reverse? What if you just want to know how many items are in the set? Surely there must be a way to get this info other than doing a counter inside a for-in-do loop?

While I'm not willing to hold my breath on this one, I do have my fingers crossed! :-)

Regards,
Robin



-------------------------
--------------------------------------
Robin Riley
Motorola, Inc
Robin.Riley@motorola.com
Report this to a Moderator Report this to a Moderator
 16-Dec-2003 15:22
User is offline View Users Profile Print this message


Tony Goodman

Posts: 1098
Joined: 12-Sep-2002

The for o in m loop respects the current display set, so you can improve efficiency by applying a filter or sort or setting the level to the module before entering the loop.
Objects can be accessed directly via their absolute number, e.g. o = object(23)

Not much help I know, but I can't think of another way.

-------------------------
Tony Goodman
http://www.smartdxl.com
Report this to a Moderator Report this to a Moderator
 5-Jan-2004 14:55
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

I agree with the Gallion. To which I add... If you plan to do a lot of searching then you might as well put the "stuff" in a Skip list and then search for it there. This is less effecient than programming it but more effecient; much more efficient execution style. The major down side is when you add or remove a "stuff" you need to update your Skip.

For example, a script you may write to link the current module to specific objects in a target module will work more effeciently if you put all the target objects in a skip, using the int AbsNo and Object handle, and then search the Skip.

- Louie

Edited: 5-Jan-2004 at 14:57 by Louie Landale
Report this to a Moderator Report this to a Moderator
 5-Jan-2004 14:56
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

I agree with the Gallion. To which I add... If you plan to do a lot of searching then you might as well put the "stuff" in a Skip list and then search for it there. This is less effecient than programming it but more effecient; much more efficient execution style. The major down side is when you add or remove a "stuff" you need to update your Skip.

For example, a script you may write to link the current module to specific objects in a target module will work more effeciently if you put all the target objects in a skip, using the int AbsNo and Object handle, and then search the Skip.

- Louide
Report this to a Moderator Report this to a Moderator
 5-Jan-2004 17:48
User is offline View Users Profile Print this message


Robin Riley

Posts: 4
Joined: 15-Aug-2003

Hi,

Thanks for your responses... I guess basically I'm just spoiled from working with real languages (e.g. C, C++, etc) and the convenience of being able to go in either direction, being able to "bookmark" a certain location in the collection (via pointers), etc. I feel like someone's taken away my ferrari and given me a hugo. :-)

Specifically, all I want to do is to be able to grab the last history record of type modifyObject for a given object. Since I want the most recent one, it just seems silly to have to start from the beginning and work my way through to the last one, y'know?

As for looping in reverse and how to figure out how to order items, huh??? The order of the items in the collection would not change. It's just that you would start at the end and go backwards. Something akin to:

for historyRec in obj step -1
{
if (historyRec.type == modifyObject)
{
// Found it! Now go do whatever with it and exit the loop.
}
}

Robin


-------------------------
--------------------------------------
Robin Riley
Motorola, Inc
Robin.Riley@motorola.com
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
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.