show partial string from another attribute

Hello, sorry another novice question...I've created this attribute from the DOORS wizard:

// DXL generated on 15 March 2013 by Attribute DXL wizard, Version 1.0

// The wizard will use the following comments on subsequent runs
// to determine the selected options and attributes. It will not
// take account of any manual changes in the body of the DXL code.

// begin parameters (do not edit)
// One attribute/property per line: true
// Show attribute/property names: false
// Include OLE objects in text: false
// Attribute: Verification IDs
// end parameters (do not edit)

Module m
AttrDef ad
AttrType at
m = module obj
ad = find(m,attrDXLName)
if(!null ad && ad.object)
{
at = ad.type
if(at.type == attrText)
{
string s
Buffer val = create
Buffer temp = create
ad = find(m,"Verification IDs")
if(!null ad)
{
probeRichAttr_(obj,"Verification IDs", temp, false)
val += tempStringOf temp
}
obj.attrDXLName = richText (tempStringOf val)
delete val
delete temp
}
}

This code in this attribute simply duplicates the data from another attribute. I would like to modify the code such that for each data is the "Verification IDs" attribute(e.g.: MEM1234), I only show the first three characters: MEM.

maybe i need to go a simpler route?

Thanks, John
btela2000 - Sat Mar 16 00:58:17 EDT 2013

Re: show partial string from another attribute
SystemAdmin - Sat Mar 16 10:54:27 EDT 2013

Do you mean?
 

string sSomething = "MEM123434";
string sPartOfSomething = sSomething[0,3];

Re: show partial string from another attribute
llandale - Sat Mar 16 13:45:11 EDT 2013

This:
  • string s = "12345678"
should print:
  • 123 4567
Note that digit "1" is in position "0".

So to fix your code, change line:
  • val += tempStringOf temp
to+
  • val += (tempStringOf temp)0:2

I see you want the 1st 3 RAW text character, not the 1st 3 rich text (which may be tags), in which you use "probeAttr_" instead of "probeRichAttr_.

Or better yet, scrap that entire code and do this:
  • obj.attrDXLName = probeAttr_(o, "Verification IDs")0:2

-Louie

Re: show partial string from another attribute
btela2000 - Mon Mar 18 13:52:12 EDT 2013

llandale - Sat Mar 16 13:45:11 EDT 2013
This:

  • string s = "12345678"
should print:
  • 123 4567
Note that digit "1" is in position "0".

So to fix your code, change line:
  • val += tempStringOf temp
to+
  • val += (tempStringOf temp)0:2

I see you want the 1st 3 RAW text character, not the 1st 3 rich text (which may be tags), in which you use "probeAttr_" instead of "probeRichAttr_.

Or better yet, scrap that entire code and do this:
  • obj.attrDXLName = probeAttr_(o, "Verification IDs")0:2

-Louie

Hey Louie,

I truly appreciate the fast response! thank you! I just tried your code correction here:

/ DXL generated on 15 March 2013 by Attribute DXL wizard, Version 1.0

// The wizard will use the following comments on subsequent runs
// to determine the selected options and attributes. It will not
// take account of any manual changes in the body of the DXL code.

// begin parameters (do not edit)
// One attribute/property per line: true
// Show attribute/property names: false
// Include OLE objects in text: false
// Attribute: Verification IDs
// end parameters (do not edit)

Module m
AttrDef ad
AttrType at
m = module obj
ad = find(m,attrDXLName)
if(!null ad && ad.object)
{
at = ad.type
if(at.type == attrText)
{
string s
Buffer val = create
Buffer temp = create
ad = find(m,"Verification IDs")
if(!null ad)
{
probeRichAttr_(obj,"Verification IDs", temp, false)
val += (tempStringOf temp)0:2
}
obj.attrDXLName = richText (tempStringOf val)
delete val
delete temp
}
}
------------------------------I get the following errors:
-E- DXL: <Line:31> incorrectly concatenated tokens
-E- DXL: <Line:31> syntax error
-I- DXL: All done. Errors reported: 2. Warnings reported: 0.
I also tried to run your simple script and I couldnt't do that either. defintely a novice. maybe its how i put it it. I just tried your simple:
•string s = "12345678"
◦print s0:2 "\t" s3:6 "\n"
here's what I put into the dxl window:
string s = "12345678"
print s0:2 "\t" s3:6 "\n"
got these errors:
-E- DXL: <Line:2> incorrect arguments for function (print)
-E- DXL: <Line:2> undeclared variable (s0)
-E- DXL: <Line:2> syntax error
-I- DXL: All done. Errors reported: 3. Warnings reported: 0.

sorry if im not getting the simpler things right now. thank you, John

Re: show partial string from another attribute
llandale - Mon Mar 18 16:10:05 EDT 2013

btela2000 - Mon Mar 18 13:52:12 EDT 2013
Hey Louie,

I truly appreciate the fast response! thank you! I just tried your code correction here:

/ DXL generated on 15 March 2013 by Attribute DXL wizard, Version 1.0

// The wizard will use the following comments on subsequent runs
// to determine the selected options and attributes. It will not
// take account of any manual changes in the body of the DXL code.

// begin parameters (do not edit)
// One attribute/property per line: true
// Show attribute/property names: false
// Include OLE objects in text: false
// Attribute: Verification IDs
// end parameters (do not edit)

Module m
AttrDef ad
AttrType at
m = module obj
ad = find(m,attrDXLName)
if(!null ad && ad.object)
{
at = ad.type
if(at.type == attrText)
{
string s
Buffer val = create
Buffer temp = create
ad = find(m,"Verification IDs")
if(!null ad)
{
probeRichAttr_(obj,"Verification IDs", temp, false)
val += (tempStringOf temp)0:2
}
obj.attrDXLName = richText (tempStringOf val)
delete val
delete temp
}
}
------------------------------I get the following errors:
-E- DXL: <Line:31> incorrectly concatenated tokens
-E- DXL: <Line:31> syntax error
-I- DXL: All done. Errors reported: 2. Warnings reported: 0.
I also tried to run your simple script and I couldnt't do that either. defintely a novice. maybe its how i put it it. I just tried your simple:
•string s = "12345678"
◦print s0:2 "\t" s3:6 "\n"
here's what I put into the dxl window:
string s = "12345678"
print s0:2 "\t" s3:6 "\n"
got these errors:
-E- DXL: <Line:2> incorrect arguments for function (print)
-E- DXL: <Line:2> undeclared variable (s0)
-E- DXL: <Line:2> syntax error
-I- DXL: All done. Errors reported: 3. Warnings reported: 0.

sorry if im not getting the simpler things right now. thank you, John

My bad, I forgot to preview the message before I posted. On the forums, something surrounded with backets [ and ] is interpreted as a URL. So typing "a[0:2]" looks like "a0:2". Solution is to escape the first or both with a backslash, typed like this: "a:\[0:2\]" it looks like "a[0:2]"

  • string s = "12345678"
  • print s[0:2] "\t" s[3:6] "\n"

The brackets mean "substring range".

-Louie

Re: show partial string from another attribute
btela2000 - Mon Mar 18 18:56:08 EDT 2013

llandale - Mon Mar 18 16:10:05 EDT 2013
My bad, I forgot to preview the message before I posted. On the forums, something surrounded with backets [ and ] is interpreted as a URL. So typing "a[0:2]" looks like "a0:2". Solution is to escape the first or both with a backslash, typed like this: "a:\[0:2\]" it looks like "a[0:2]"

  • string s = "12345678"
  • print s[0:2] "\t" s[3:6] "\n"

The brackets mean "substring range".

-Louie

Hey Louie,

thanks for the clarification. I was able to get the code to have no syntax errors, but then I got the popular "Attribute DXL Failed." It stated that it failed because it was not in rich text format. i suspect its choking on teh fact that Verification IDs (teh attribute it is analyzing) is not in rich text.
here's the error:
-R-E- DXL: <Line:33> String is not in rich text format
-I- DXL: execution halted

So tried to scrap that entire code and put in this line per your suggestion:

\\\\\\\\\
Module m
obj.attrDXLName = probeAttr_(obj, "Verification IDs")0:2
\\\\\\\\\\
I did confirm that it does work when I dont have the "0:2" in it.

thanks, John

Re: show partial string from another attribute
btela2000 - Mon Mar 18 21:49:11 EDT 2013

btela2000 - Mon Mar 18 18:56:08 EDT 2013
Hey Louie,

thanks for the clarification. I was able to get the code to have no syntax errors, but then I got the popular "Attribute DXL Failed." It stated that it failed because it was not in rich text format. i suspect its choking on teh fact that Verification IDs (teh attribute it is analyzing) is not in rich text.
here's the error:
-R-E- DXL: <Line:33> String is not in rich text format
-I- DXL: execution halted

So tried to scrap that entire code and put in this line per your suggestion:

\\\\\\\\\
Module m
obj.attrDXLName = probeAttr_(obj, "Verification IDs")0:2
\\\\\\\\\\
I did confirm that it does work when I dont have the "0:2" in it.

thanks, John

I took another crack at it and it works! Thank you!

here's the code:

obj.attrDXLName = (probeAttr_(obj, "Verification IDs"))0:2

Re: show partial string from another attribute
btela2000 - Mon Mar 18 21:49:15 EDT 2013

btela2000 - Mon Mar 18 18:56:08 EDT 2013
Hey Louie,

thanks for the clarification. I was able to get the code to have no syntax errors, but then I got the popular "Attribute DXL Failed." It stated that it failed because it was not in rich text format. i suspect its choking on teh fact that Verification IDs (teh attribute it is analyzing) is not in rich text.
here's the error:
-R-E- DXL: <Line:33> String is not in rich text format
-I- DXL: execution halted

So tried to scrap that entire code and put in this line per your suggestion:

\\\\\\\\\
Module m
obj.attrDXLName = probeAttr_(obj, "Verification IDs")0:2
\\\\\\\\\\
I did confirm that it does work when I dont have the "0:2" in it.

thanks, John

I took another crack at it and it works! Thank you!

here's the code:

obj.attrDXLName = (probeAttr_(obj, "Verification IDs"))0:2

Re: show partial string from another attribute
btela2000 - Mon Mar 18 22:27:56 EDT 2013

btela2000 - Mon Mar 18 21:49:15 EDT 2013
I took another crack at it and it works! Thank you!

here's the code:

obj.attrDXLName = (probeAttr_(obj, "Verification IDs"))0:2

too funny and now i get the how to show the text...let me try now:

obj.attrDXLName = (probeAttr_(obj, "Verification IDs"))[0:2]