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: do operator
Topic Summary:
Created On: 13-Dec-2007 07:56
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.
 13-Dec-2007 07:56
User is offline View Users Profile Print this message


Mattias Johansson

Posts: 14
Joined: 5-Jul-2004

Hi All!

I'm currently experimenting with my own do operator. The syntax for this is

void ::do (Type&, Type, void)

ex
void ::do (string &s, Buffer b, void v) {
print "Testing\n"
s = "Testing2\n"
}
String s
Buffer b = create
for s in b do {
print s
}

I do not, however, make it work...

The s variable does not seem to be assigned. However (if you comment the "print s" line) it prints "Testing", so the function is called.
I do not know what the void v actually stands for either...

Has anybody succeeded in making your own do operator?

/Mattias
Report this to a Moderator Report this to a Moderator
 13-Dec-2007 10:10
User is offline View Users Profile Print this message


Tony Goodman

Posts: 1098
Joined: 12-Sep-2002

Never tried, but I'll put money on Reik knowing how to do it ;-)

-------------------------
Tony Goodman
http://www.smartdxl.com
Report this to a Moderator Report this to a Moderator
 13-Dec-2007 18:07
User is offline View Users Profile Print this message


Eric Piallat

Posts: 13
Joined: 10-Dec-2007

From the DOORS API manual:
This example creates a for..do loop. Entry is the TXL data type representing a
C Entry* variable, and is the type of the scan variable. Table is the TXL data
type representing a C Table* variable, and is the parent of the scan.
BEGIN_FOR_DO(tdsDoFn,Table*,tab,Entry*,scan)
tdsDo(tab,scan) {
PROCESS_DO(scan);
}
END_FOR_DO

apiInstall("void ::do(Entry&, Table, void)", tdsDoFn);


What I understand from this is that the PROCESS_DO declaration allows inserting the body of the loop inside your do function.

In fact, your ::do function shall call PROCESS_DO at the point where your iterator is ready for use, in order to actually execute the "print s" line.

And I honestly have no idea about how to do that with dxl. My guess is that it wasn't even planed, and that do loops can only be defined through the C API.
But I'd gladly be wrong about that, as I tried hard to create a "for string in buffer" loop myself !
Report this to a Moderator Report this to a Moderator
 13-Dec-2007 18:08
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Don't know, but its spelled 'string' not 'String'. I'd assign some value to the buffer, perhaps 'b = "abc".

Let me think. For a 'do' loop to work, there must be an initial condition, some change each time its called, and a mechanism for ending the loop. If so, it seems as though the Mystery call-parameter function could realistically do the initialization code, and the do loop itself figure out when its finished.

Attached find my feeble attempt at this. Doesn't work. I find it VERY interesting that the '>Loop' gets printed before the 'do', suggesting we get INTO the loop before the do code is called. That can't be right.

- Louie
Report this to a Moderator Report this to a Moderator
 14-Dec-2007 07:44
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

Hi Mattias,

unfortunately Tony lost the bet

I've tried to that many times with many variants, but never succeeded.
I found the same behaviour as you are describing - it works when you do not use the loop variable inside body code

Additionally I tried to declare the void function explicitly and then do an explicit call to the "do" function -> that works, but is not usefull

It seem, that Eric is right. "for ... do" loops can only be defined with C-Api, but unfortunately it is AFAIK not possible to add programmig features to existing DXL.
The C-Api will create a new language with no possibilities to access the database direcly.

Sorry for that bad news (esspeacially for Tony, who lost his money )
Have a nice weekend,
greetings
Reik

-------------------------
Evosoft GmbH
for Siemens Industry Sector


Berlin, Germany
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 2 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 2 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.