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: DXL Function Please
Topic Summary:
Created On: 19-Mar-2004 16:11
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.
Answer This question was answered by , on Monday, March 22, 2004 2:50 PM

Answer:
Louie,

One way to do this is with DXL Regular Expressions, like so:
 19-Mar-2004 16:11
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Anybody help me out on this?

I've got Text that may have parenthetical expressions embedded in it and I need to parsed and broken apart. The expressions are bracketed and internally separated by a colon: [text1:text2]. I need to know if there is such an expression in the text, and if so brake the entire text apart. Thus if Text = "This is Text [with legal:Expression] and it continues [aa:bb]"
then I need it separated into:
Text0 = "This is Text "
Text1 = "with legal"
Text2 = "Expession"
Text3 = " and it continues [aa:bb]"

I can handle the recursive needs where Text3 (the remaining text) also contains such an expression.

So I need this function to determine if such an expression exists (colon inside of paired brackets) and if so turn it into its 4 parts.

If possible the function needs to handle RichText within the text (bolding etc; but no OLE diagrams).

- Louie
Report this to a Moderator Report this to a Moderator
 19-Mar-2004 22:11
User is offline View Users Profile Print this message


Lin Cui

Posts: 3
Joined: 19-Mar-2004

Use this:

/////////////////////////////////////////////////////////////////////////////////////
// FINDS FIRST CHARACTER OCCURANCE POSITION WITHIN A STRING
// RETURNS -1 if unsuccessful
/////////////////////////////////////////////////////////////////////////////////////
int find_char_in_string(string string_to_examine, char char_to_find)
{

string str = string_to_examine
char c
int length_of_str
int index
int found

int return_value
return_value = -1

length_of_str = length (str)
index = 0
found = 0

while ((index < length_of_str) && (found == 0))
{
c = str[index]

if (c == char_to_find)
{
found = 1
return_value = index

}
index = index + 1
}

return return_value
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

it basically finds the first occuring character in a string....in your case u want to search for '[' then find ']'
then use separate the string using YOURSTRING[return value for [, return value for ]]

then search for ':' and get that position and use the same str[,] technique to separate the expressions within the []

good luck
Report this to a Moderator Report this to a Moderator
 22-Mar-2004 14:48
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Like the vampire said, "Fang you very much". I don't know why I'm so brain-dead on regular expressions, but I just plain don't get it at all. But I can debug other people's DXL lickety-split and I can snatch coins off my elbow.

- Louie
Report this to a Moderator Report this to a Moderator
 22-Mar-2004 19:51
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Bad news. Doesn't seem to find CRs in the text. The attached code simply inserts a CR before "continues" and notice the rest of the string is chopped off of Text3. I notice that a CR in Text0 IS found.

Gotta handle CRs and TABs in the text (but ignore RichText stuff).

- Louie
Report this to a Moderator Report this to a Moderator
 23-Mar-2004 16:13
User is offline View Users Profile Print this message


Paul Tiplady

Posts: 176
Joined: 28-Oct-2003

Thet'll be because '.' in the regexp only matches printing characters (although I think it includes space and tab). Replace it with '[.\n]' in each case that you need to match thew newline and you're away. That means your regular expression becomes as shown in the code attached. You only need to change the first '.' if you think you might get a newline immediately after the opening bracket (which I think is highly unlikely -- so it's bound to happen ).

I'd check it, but we've run out of licences (again).

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


Paul dot Tiplady at TRW dot com
TRW Automotive
Report this to a Moderator Report this to a Moderator
 25-Mar-2004 14:01
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

I guess I'll have to check for TABs as well: [ \n\t]. It also appears I'll have to check for repeated brackecks in the text, such as a[b[c:e]f. I believe that SHOULD be a[b [ c : d:e ] f.

RegularExpressions bite. So does the RichText I've been forced to deal with (since "a" can be bolded).

- Louie
Report this to a Moderator Report this to a Moderator
 29-Mar-2004 12:08
User is offline View Users Profile Print this message


Kristian Bøe

Posts: 29
Joined: 16-Jun-2003

Why not just an uggly brute force string - char check?

The example will below will extract the bracketed info and should be easy to modifies to include beginning and ending...


-------------------------
Kristian Bøe
Extenda AB
Kristian.Boe@extenda.se
Report this to a Moderator Report this to a Moderator
 29-Mar-2004 15:14
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Being too brain dead on RegExp I ended up doing it the "hard" way as well.
I looked for the positions of "[", ":", "]" in the text resulting in strings
A[B:C]D, but had to adjust for the case where "A" or "B" contained another "[",
in which case I just shortened the string to start at that location-1; and searced
again. C containing a "[" or ":" didn't matter. If I found such a pattern I ended
up searching through D.

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