![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
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 |
![]() |
![]()
|
![]() |
|
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 office 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 |
|
![]() |
|
![]() |
|
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-3 else print "Failed to match" |
|
![]() |
|
![]() |
|
The form software must of converted colon O to a smiley face |
|
![]() |
|
![]() |
|
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! -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. |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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.
|
|
![]() |
|
![]() |
|
Ed, You need to initialize i and also test that i is greater than 2 prior to using i-3.
|
|
![]() |
|
![]() |
|
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? |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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. |
|
![]() |
|
![]() |
|
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 |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
How does DXL capture character strings?
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.