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: Split by Newline
Topic Summary:
Created On: 18-Dec-2006 17:14
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 Louie Landale, on Monday, December 18, 2006 9:10 PM

Answer:
I notice you have a space before the \n that you don't want.

I'm surprised this works since you need to convert the attribute reference <obj."Name"> into a string by suffixing it with 2-double quotes:
if (matches("Jason McMan\n", obj."Name" ""))

.. but perhaps 'matches' works on attribute references.

I notice the above fails when Jason McMan is the only name in the list, or when its the last name in the list. Using regexp looks real complicated for this.

I'd parse through the values finding individual names. See the attached to get your going.

- Louie
 18-Dec-2006 17:14
User is offline View Users Profile Print this message


Mike Malloy

Posts: 9
Joined: 12-Dec-2006

Hi guys.  I'm just now getting into DXL.  I'm having a lot of trouble with the language translation from VB.  I am trying to split a cell by the carriage returns (newlines) within it.  Attribute "Name" contains the following:  ["Jason McMan" newline "Jason McManson"].

If I put the following code into the attribute where I want the result
if(matches("Jason McMan", obj."Name"))
 {
displayRich "Jason McMan is here"
}

it will display because "Jason McMan" is in there.  But if a cell contains only "Jason McManson", then it will still return "Jason McMan" because of the similarity in the names.  To solve this in VB, I would split the cell with a carriage return delimiter.  How do I do this in DXL?  I tried:

if(matches("Jason McMan \n", obj."Name"))

but it obviously doesn't work.

Thanks for the help!
Mike 

Edited: 18-Dec-2006 at 17:16 by Mike Malloy
Report this to a Moderator Report this to a Moderator
 18-Dec-2006 19:03
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Answer Answer
I notice you have a space before the \n that you don't want.

I'm surprised this works since you need to convert the attribute reference <obj."Name"> into a string by suffixing it with 2-double quotes:
if (matches("Jason McMan\n", obj."Name" ""))

.. but perhaps 'matches' works on attribute references.

I notice the above fails when Jason McMan is the only name in the list, or when its the last name in the list. Using regexp looks real complicated for this.

I'd parse through the values finding individual names. See the attached to get your going.

- Louie
Report this to a Moderator Report this to a Moderator
 18-Dec-2006 21:07
User is offline View Users Profile Print this message


Mike Malloy

Posts: 9
Joined: 12-Dec-2006

Thanks Louie.  Looks like you are pointing me in the right direction. 
Report this to a Moderator Report this to a Moderator
 18-Dec-2006 22:21
User is offline View Users Profile Print this message


Mike Malloy

Posts: 9
Joined: 12-Dec-2006

Hey Louie, just one more thing.  For now, I'm going with if(matches("Jason McMan\n", obj."Name" "")) for simplicity.  I built other tests in to see if there is only one line in the cell, etc.  But, if Attribute "Name" contains ['Jason McMan" newline "Jason McManson" newline "Jason McMan"], then the above code will return "Jason McMan is here" twice.  How can I check to make sure that if "Jason McMan" has already been returned, so it won't put it there again?  

I'm thinking something easy like if(!matches("Jason McMan is here", *****)), where "*****" is the attribute I am writing all this code for, except I don't know how to call this attribute since I created it and it's not a real attribute.

Did this make sense?

Thanks,
Mike 
Report this to a Moderator Report this to a Moderator
 22-Dec-2006 22:03
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Not for sure what you are getting at. But if you have a loop going through all the references and you encounter Jason McMan, then you can exit ..err.. break out of the loop after dealing with him.

Anyway, maybe you could suffix the attribute value with a space, and then use regular expressions to look for 'Jason McMan' immediately followed by some white space delimiters, such as ' \n\t'.

Or forget about suffixing, and do 3 compares [1] attr value is exactly Jason McMan [2] attr value matches <white space>Jason McMan [3] attr values matches Jason McMan<white Space>.

I'm clumsy with Regexp, but perhaps the definitions may look like:
string Jason = "Jason McMan"
Regexp reJason1 = regexp(Jason "( |\n|\t)")
Regexp reJason2 = regexp("( |\n|\t)" Jason)

Thus:
AttrVal = obj.MyAttr
if (AttrVal == Jason or matches(reJason1, AttrVal) or matches(reJason2, AttrVal))

- Louie
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.