![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Split by Newline Topic Summary: Created On: 18-Dec-2006 17:14 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() 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 | |
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
Thanks Louie. Looks like you are pointing me in the right direction.
|
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
Telelogic DOORS
» General Discussion
»
Split by Newline
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.