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: How does DXL capture character strings?
Topic Summary: Need help with a DXL to strip characters from an attribute
Created On: 18-Aug-2005 18:44
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.
 18-Aug-2005 18:44
User is offline View Users Profile Print this message


Ed Janonis

Posts: 10
Joined: 10-Aug-2005

I am trying to strip out several contiguous characters from the Object Text and assign it to the attribute "Max Time (sec)".   An example of the text is "...  3.0 seconds.".  My DXL was to find the term "seconds" and then back up 5 places and trim off any blanks and then assign that to the "Max Time (sec)" attribute.

This is what I have so far:

Object officeffice" />>>

Buffer temp_string = create>>

int i>>

string sTerm>>

sTerm = "seconds">>

for o in current Module do >>

{>>

temp_string = o."Object Text" "">>

i = contains(temp_string, sTerm, 0)>>

while (i > -1) >>

{>>

something goes here!!>>

}>>

o."Max Time (sec)" = stringOf(temp_string)>>

}>>

delete temp_string

Since I have never written a DXl script, it is hard for me to find out where the script errors.  All I get is Error in DXL to be posted in the attribute (I ran it without the italics line).  There is no bebugger so I cannot follow the code for erors or even see what is happening.
Can anyone help me?

Report this to a Moderator Report this to a Moderator
 18-Aug-2005 19:04
User is offline View Users Profile Print this message


ron lewis

Posts: 650
Joined: 20-Sep-2004

Try something like this

//Demo
/*By Ron Lewis*/

string s = "Time is 3 seconds till noon."

string sub = "seconds"

int offset

int len

if(findRichText(s, sub, offset, len, false))    print s[offset-3ffset+len ]

 else print "Failed to match"

Report this to a Moderator Report this to a Moderator
 18-Aug-2005 19:05
User is offline View Users Profile Print this message


ron lewis

Posts: 650
Joined: 20-Sep-2004

The form software must of converted  colon O    to a smiley face

Report this to a Moderator Report this to a Moderator
 18-Aug-2005 19:43
User is offline View Users Profile Print this message


Ed Janonis

Posts: 10
Joined: 10-Aug-2005

Ok Ron,

I saw that I needed to create an offset and change "s" and "sub" to the variables I use.  No biggie.  But wait... this is DOORS!

So here is what I did.

I get these obsurd errors.

-E- DXL: <Line:10> incorrect arguments for function (contains)

-E- DXL: <Line:17> syntax error

-I- DXL: all done with 2 errors and 0 warnings

Now I have only 16 lines of code and there is nothing wrong with the contains() funtion that I can see.

Report this to a Moderator Report this to a Moderator
 18-Aug-2005 19:59
User is offline View Users Profile Print this message


Chris Jones

Posts: 177
Joined: 1-Jul-2005

Ed,
Try getting rid of one of the closing curly braces.....you've got two of them, but only one opening
Don't feel bad, I do things like that quite often.

And, slightly off-topic, is it just me, or does this forum really likes to make things more fun, to spice up posts a little bit? I love all the smilies everywhere in code!

Chris
Report this to a Moderator Report this to a Moderator
 18-Aug-2005 20:14
User is offline View Users Profile Print this message


Ed Janonis

Posts: 10
Joined: 10-Aug-2005

I got rid of the extra "}".  Figures.  I still get DXL errors.  I am about to quit!  I added a check to make sure that contains returns a positive number.  But I get an error.  Not when I run check but when I run the DXL.  All that is placed in the new column is Error in DXL.  I fixed the IF() error (I found out that the contain needs a Buffer not a string.).  Beyond that it is all smoke and magic to me.
Report this to a Moderator Report this to a Moderator
 18-Aug-2005 23:17
User is offline View Users Profile Print this message


ron lewis

Posts: 650
Joined: 20-Sep-2004

Ed, You need to initialize i and also test that i is greater than 2 prior to using i-3.
Report this to a Moderator Report this to a Moderator
 19-Aug-2005 15:14
User is offline View Users Profile Print this message


Ed Janonis

Posts: 10
Joined: 10-Aug-2005

Ok I think I have narrowed it down.  I created a module that contains 2 objects.  Each has the key word at location 226.  The script prints i=226 and sText=3.0 and i=226 and sText=8.0.  Then it goes into an infinite loop of something.  It continues to print i=226 and sText=3.0.  The only way out is to abort DOORS.  I never see the update to the attribute "Max Time (sec)" because of the never ending loop syndrome.

What in the code is causing that?
Report this to a Moderator Report this to a Moderator
 22-Aug-2005 09:20
User is offline View Users Profile Print this message


Paul Tiplady

Posts: 176
Joined: 28-Oct-2003

Ed,

I don't fully understand what's going on with the while loop, which is clearly infinite - nothing changes the value of i in the while loop, so if it's greater than 7 on the way in, it will always be greater than 7, and never exit.

So, why is the line 'i = contains(bObjString, sTerm, 0)' commented out? This is the only line that could update i, and so it really needs to be run. However, it needs to not find the string it just found, so the '0' needs to be replaced with ' ( i + 1 ) ' to prevent this redetection. If the string isn't found again, i will become -1 and the loop will exit.

In short, swap '//i = contains(bObjString, sTerm, 0)' with 'i = contains(bObjString, sTerm, ( i + 1 ) )'

Does that fix it?

Paul.

-------------------------


Paul dot Tiplady at TRW dot com
TRW Automotive
Report this to a Moderator Report this to a Moderator
 22-Aug-2005 15:06
User is offline View Users Profile Print this message


Ed Janonis

Posts: 10
Joined: 10-Aug-2005

I appreciate all your assistance in my effort to write my first DXL script.  After spending 5 hours and getting absolutely nowhere, I resorted back to my sure fire method.  I exported the file in excel and did all the string extractions needed.  I wrote the VBA script in 30 minutes and reimported it into DOORS.  The only drawback I have is that I have to perform this every update of the DOORS module.  That was the real reason I wanted a DXL script.

Thanks again.
Report this to a Moderator Report this to a Moderator
 9-Sep-2005 22:49
User is offline View Users Profile Print this message


Shawn Stepper

Posts: 96
Joined: 6-Aug-2004

Here is a "strip" function for stipping characters out of a string or a buffer. Maybe this will help you do what you want.

-------------------------
Shawn Stepper
shawn.e.stepper@wellsfargo.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.