Displaying text or objects from one module to the other using links

So, by sceario is I have two modules, one the source and the other the destination.  What I would like to do is link from the source to the destination, and have the text or image from the source appear in the destination module, via the link.  I can get it to work for text, but I am not able to get it to work for images.

I just want to maintain text or images in the source module, while dynamically updating the destination module using the link, is that possible? 


djs1 - Tue Nov 12 12:04:24 EST 2013

Re: Displaying text or objects from one module to the other using links
GregM_dxler - Tue Nov 12 13:45:51 EST 2013

Hi,

It depends a bit on the image.  Use richTextWithOle works for me in most cases.

Not sure what you mean by maintaining text or images in source while updating the destination module.  You would need to make the changes to the text and image in the source module, not the destination.

Maybe it would help if you added what your current dxl is?

Greg

Re: Displaying text or objects from one module to the other using links
llandale - Tue Nov 12 13:47:51 EST 2013

You create the links manually.

The standard way for most folks to display info of linked objects is:

  • Use the Analysis Wizard to create a Layout displaying some information of the linked object.  Re-run the wizard until you are happy it is finding the correct linked objects to display.
  • If you don't see exactly the info you want, then edit the Layout DXL code near the "s=" and "display" commands.
  • When the layout is satisfactory, use the tool to convert it into an Attr-DXL.  Save the module.
  • Delete the layouts, add the attr-DXL to the view, save the view

In your specific case I'm guessing the Layout is retrieving and displaying raw text.  You will need to edit the layout..

  • Find <othero."Object Text"> and change to <richTextWithOle(othero."Object Text")>
  • change <display s> to <displayRich s>.

When you give up on that, post the layout code and someone will tweak it for you.

-Louie

While layouts are reasonable for simple displays; displaying linked objects (and other rather intense code) is a disaster in Layouts since it gets run extremely frequently; 10 times a second while you move the module window around.  Attr-DXL runs a single time (after opening module and displaying object).

Re: Displaying text or objects from one module to the other using links
djs1 - Tue Nov 12 14:03:39 EST 2013

GregM_dxler - Tue Nov 12 13:45:51 EST 2013

Hi,

It depends a bit on the image.  Use richTextWithOle works for me in most cases.

Not sure what you mean by maintaining text or images in source while updating the destination module.  You would need to make the changes to the text and image in the source module, not the destination.

Maybe it would help if you added what your current dxl is?

Greg

Here is my code:

/*
    This attribute DXL was generated on 11/7/2013 09:34:00.
*/

// prevent dxl timeout dialog
pragma runLim, 0

Buffer bsz = create

void endAttributeDXL()
{
    if (!null obj && attrDXLName != "")
    {
        obj.attrDXLName = richText tempStringOf(bsz)
    }

    delete bsz
}

void addNewLineSeparator(Buffer& b)
{
    if (length(b) > 0)
    {
        b += "\n"
    }
}

void display(string s)
{
    addNewLineSeparator(bsz)
    bsz += s
}

void displayRich(string s)
{
    addNewLineSeparator(bsz)
    bsz += s
}

void displayRichWithColour(string s)
{
    addNewLineSeparator(bsz)
    bsz += s
}

void displayRichWithColor(string s)
{
    addNewLineSeparator(bsz)
    bsz += s
}

void display(Attr__ a)
{
    string s = richText a
    if (!null s)
    {
        displayRich s
    }
}

//**********

// DXL generated by DOORS traceability wizard on 07 November 2013.
// Wizard version 2.0, DOORS version 9.3.0.7
pragma runLim, 0
string limitModules[1] = {"435e28fe18492417-0000a161"}
void showIn(Object o, int depth) {
    Link l
    LinkRef lr
    ModName_ otherMod = null
    Module linkMod = null
    ModuleVersion otherVersion = null
    Object othero
    string disp = null
    string s = null
    string plain, plainDisp
    int plainTextLen
    int count
    bool doneOne = false
    Item linkModItem = itemFromID("435e28fe18492417-0000a17d")
    if (null linkModItem) {
        displayRich("\\pard " "<<Link module not found>>")
    } else if (type(linkModItem) != "Link") {
        displayRich("\\pard " "<<Invalid link module index for this database>>")
    } else {
        string linkModName = fullName(linkModItem)
        for lr in all(o<-linkModName) do {
            otherMod = module (sourceVersion lr)
            if (!null otherMod) {
                if ((!isDeleted otherMod) && (null data(sourceVersion lr))) {
                    if (!equal(getItem otherMod, (itemFromID limitModules[depth-1]))) continue
                    load((sourceVersion lr),false)
                }
            }
        }
        for l in all(o<-linkModName) do {
            otherVersion = sourceVersion l
            otherMod = module(otherVersion)
            if (null otherMod || isDeleted otherMod) continue
            if (!equal(getItem otherMod, (itemFromID limitModules[depth-1]))) continue
            othero = source l
            if (null othero) {
                load(otherVersion,false)
            }
            othero = source l
            if (null othero) continue
            if (isDeleted othero) continue
            doneOne = true
            if (depth == 1) {
                s = probeRichAttr_(othero,"Object Text", false)
                if (s == "")
                displayRich("\\pard " " ")
                else
                displayRich("\\pard " s)
            }
        }
    }
    if (depth == 1) {
        ExternalLink extLink
        doneOne = false
        for extLink in o<-"" do {
            if (!doneOne) {
                displayRich("\\pard " "{\\b External Links:}")
                doneOne = true
            }
        }
    }
}
showIn(obj,1)

//**********

endAttributeDXL()

Re: Displaying text or objects from one module to the other using links
djs1 - Tue Nov 12 14:46:39 EST 2013

llandale - Tue Nov 12 13:47:51 EST 2013

You create the links manually.

The standard way for most folks to display info of linked objects is:

  • Use the Analysis Wizard to create a Layout displaying some information of the linked object.  Re-run the wizard until you are happy it is finding the correct linked objects to display.
  • If you don't see exactly the info you want, then edit the Layout DXL code near the "s=" and "display" commands.
  • When the layout is satisfactory, use the tool to convert it into an Attr-DXL.  Save the module.
  • Delete the layouts, add the attr-DXL to the view, save the view

In your specific case I'm guessing the Layout is retrieving and displaying raw text.  You will need to edit the layout..

  • Find <othero."Object Text"> and change to <richTextWithOle(othero."Object Text")>
  • change <display s> to <displayRich s>.

When you give up on that, post the layout code and someone will tweak it for you.

-Louie

While layouts are reasonable for simple displays; displaying linked objects (and other rather intense code) is a disaster in Layouts since it gets run extremely frequently; 10 times a second while you move the module window around.  Attr-DXL runs a single time (after opening module and displaying object).

/*
    This attribute DXL was generated on 11/7/2013 09:34:00.
*/

// prevent dxl timeout dialog
pragma runLim, 0

Buffer bsz = create

void endAttributeDXL()
{
    if (!null obj && attrDXLName != "")
    {
        obj.attrDXLName = richText tempStringOf(bsz)
    }

    delete bsz
}

void addNewLineSeparator(Buffer& b)
{
    if (length(b) > 0)
    {
        b += "\n"
    }
}

void display(string s)
{
    addNewLineSeparator(bsz)
    bsz += s
}

void displayRich(string s)
{
    addNewLineSeparator(bsz)
    bsz += s
}

void displayRichWithColour(string s)
{
    addNewLineSeparator(bsz)
    bsz += s
}

void displayRichWithColor(string s)
{
    addNewLineSeparator(bsz)
    bsz += s
}

void display(Attr__ a)
{
    string s = richText a
    if (!null s)
    {
        displayRich s
    }
}

//**********

// DXL generated by DOORS traceability wizard on 07 November 2013.
// Wizard version 2.0, DOORS version 9.3.0.7
pragma runLim, 0
string limitModules[1] = {"435e28fe18492417-0000a161"}
void showIn(Object o, int depth) {
    Link l
    LinkRef lr
    ModName_ otherMod = null
    Module linkMod = null
    ModuleVersion otherVersion = null
    Object othero
    string disp = null
    string s = null
    string plain, plainDisp
    int plainTextLen
    int count
    bool doneOne = false
    Item linkModItem = itemFromID("435e28fe18492417-0000a17d")
    if (null linkModItem) {
        displayRich("\\pard " "<<Link module not found>>")
    } else if (type(linkModItem) != "Link") {
        displayRich("\\pard " "<<Invalid link module index for this database>>")
    } else {
        string linkModName = fullName(linkModItem)
        for lr in all(o<-linkModName) do {
            otherMod = module (sourceVersion lr)
            if (!null otherMod) {
                if ((!isDeleted otherMod) && (null data(sourceVersion lr))) {
                    if (!equal(getItem otherMod, (itemFromID limitModules[depth-1]))) continue
                    load((sourceVersion lr),false)
                }
            }
        }
        for l in all(o<-linkModName) do {
            otherVersion = sourceVersion l
            otherMod = module(otherVersion)
            if (null otherMod || isDeleted otherMod) continue
            if (!equal(getItem otherMod, (itemFromID limitModules[depth-1]))) continue
            othero = source l
            if (null othero) {
                load(otherVersion,false)
            }
            othero = source l
            if (null othero) continue
            if (isDeleted othero) continue
            doneOne = true
            if (depth == 1) {
                s = probeRichAttr_(othero,"Object Text", false)
                if (s == "")
                displayRich("\\pard " " ")
                else
                displayRich("\\pard " s)
            }
        }
    }
    if (depth == 1) {
        ExternalLink extLink
        doneOne = false
        for extLink in o<-"" do {
            if (!doneOne) {
                displayRich("\\pard " "{\\b External Links:}")
                doneOne = true
            }
        }
    }
}
showIn(obj,1)

//**********

endAttributeDXL()

Re: Displaying text or objects from one module to the other using links
GregM_dxler - Tue Nov 12 15:51:43 EST 2013

djs1 - Tue Nov 12 14:03:39 EST 2013

Here is my code:

/*
    This attribute DXL was generated on 11/7/2013 09:34:00.
*/

// prevent dxl timeout dialog
pragma runLim, 0

Buffer bsz = create

void endAttributeDXL()
{
    if (!null obj && attrDXLName != "")
    {
        obj.attrDXLName = richText tempStringOf(bsz)
    }

    delete bsz
}

void addNewLineSeparator(Buffer& b)
{
    if (length(b) > 0)
    {
        b += "\n"
    }
}

void display(string s)
{
    addNewLineSeparator(bsz)
    bsz += s
}

void displayRich(string s)
{
    addNewLineSeparator(bsz)
    bsz += s
}

void displayRichWithColour(string s)
{
    addNewLineSeparator(bsz)
    bsz += s
}

void displayRichWithColor(string s)
{
    addNewLineSeparator(bsz)
    bsz += s
}

void display(Attr__ a)
{
    string s = richText a
    if (!null s)
    {
        displayRich s
    }
}

//**********

// DXL generated by DOORS traceability wizard on 07 November 2013.
// Wizard version 2.0, DOORS version 9.3.0.7
pragma runLim, 0
string limitModules[1] = {"435e28fe18492417-0000a161"}
void showIn(Object o, int depth) {
    Link l
    LinkRef lr
    ModName_ otherMod = null
    Module linkMod = null
    ModuleVersion otherVersion = null
    Object othero
    string disp = null
    string s = null
    string plain, plainDisp
    int plainTextLen
    int count
    bool doneOne = false
    Item linkModItem = itemFromID("435e28fe18492417-0000a17d")
    if (null linkModItem) {
        displayRich("\\pard " "<<Link module not found>>")
    } else if (type(linkModItem) != "Link") {
        displayRich("\\pard " "<<Invalid link module index for this database>>")
    } else {
        string linkModName = fullName(linkModItem)
        for lr in all(o<-linkModName) do {
            otherMod = module (sourceVersion lr)
            if (!null otherMod) {
                if ((!isDeleted otherMod) && (null data(sourceVersion lr))) {
                    if (!equal(getItem otherMod, (itemFromID limitModules[depth-1]))) continue
                    load((sourceVersion lr),false)
                }
            }
        }
        for l in all(o<-linkModName) do {
            otherVersion = sourceVersion l
            otherMod = module(otherVersion)
            if (null otherMod || isDeleted otherMod) continue
            if (!equal(getItem otherMod, (itemFromID limitModules[depth-1]))) continue
            othero = source l
            if (null othero) {
                load(otherVersion,false)
            }
            othero = source l
            if (null othero) continue
            if (isDeleted othero) continue
            doneOne = true
            if (depth == 1) {
                s = probeRichAttr_(othero,"Object Text", false)
                if (s == "")
                displayRich("\\pard " " ")
                else
                displayRich("\\pard " s)
            }
        }
    }
    if (depth == 1) {
        ExternalLink extLink
        doneOne = false
        for extLink in o<-"" do {
            if (!doneOne) {
                displayRich("\\pard " "{\\b External Links:}")
                doneOne = true
            }
        }
    }
}
showIn(obj,1)

//**********

endAttributeDXL()

Try changing s = probeRichAttr_(othero,"Object Text", false)

to s = richTextWithOle othero."Object Text"

Greg
 

Re: Displaying text or objects from one module to the other using links
djs1 - Wed Nov 13 08:17:37 EST 2013

GregM_dxler - Tue Nov 12 13:45:51 EST 2013

Hi,

It depends a bit on the image.  Use richTextWithOle works for me in most cases.

Not sure what you mean by maintaining text or images in source while updating the destination module.  You would need to make the changes to the text and image in the source module, not the destination.

Maybe it would help if you added what your current dxl is?

Greg

Thanks Greg,

That worked, but the picture is in the DXL for In-Links Column, is there a way to place that image into the actual object text, like I was able to do for the tables?  If not, no big deal, I am greatly appreciated with all the help you have given me.

Thanks in Advance,

Dan

Re: Displaying text or objects from one module to the other using links
GregM_dxler - Wed Nov 13 08:32:35 EST 2013

djs1 - Wed Nov 13 08:17:37 EST 2013

Thanks Greg,

That worked, but the picture is in the DXL for In-Links Column, is there a way to place that image into the actual object text, like I was able to do for the tables?  If not, no big deal, I am greatly appreciated with all the help you have given me.

Thanks in Advance,

Dan

To put the text and picture in the object text instead of the DXL for In-Links Column, you would change the line

displayRich("\\pard " s)
 

With obj."Object Text" "" = richText "\\pard" s ""

Note that this will overwrite anything that is in there right now.

Hope this helps,

Greg

Re: Displaying text or objects from one module to the other using links
djs1 - Wed Nov 13 08:53:39 EST 2013

GregM_dxler - Wed Nov 13 08:32:35 EST 2013

To put the text and picture in the object text instead of the DXL for In-Links Column, you would change the line

displayRich("\\pard " s)
 

With obj."Object Text" "" = richText "\\pard" s ""

Note that this will overwrite anything that is in there right now.

Hope this helps,

Greg

It did not work, gave me the following errors,

-E- DXL: <Line:52> incorrect arguments for (=)
-E- DXL: <Line:49> incorrect arguments for (if)
-I- DXL: All done. Errors reported: 2. Warnings reported: 0.52

but thanks anyway.

Re: Displaying text or objects from one module to the other using links
GregM_dxler - Wed Nov 13 09:06:53 EST 2013

djs1 - Wed Nov 13 08:53:39 EST 2013

It did not work, gave me the following errors,

-E- DXL: <Line:52> incorrect arguments for (=)
-E- DXL: <Line:49> incorrect arguments for (if)
-I- DXL: All done. Errors reported: 2. Warnings reported: 0.52

but thanks anyway.

Try getting rid of the 2 double quotes before the equal sign.

Re: Displaying text or objects from one module to the other using links
djs1 - Wed Nov 13 13:07:16 EST 2013

GregM_dxler - Wed Nov 13 09:06:53 EST 2013

Try getting rid of the 2 double quotes before the equal sign.

Thank you very much, your suggestions worked perfectly. 

Sincerely,

 

Dan

Re: Displaying text or objects from one module to the other using links
llandale - Wed Nov 13 13:41:40 EST 2013

Looks like GregM posted while I was typing.  Did his thread resolve your issue?

While you CAN use Layouts/Attr-DXL to modify attributes I think it poor practice.  But if you do don't forget:

  • if (!canModify(obj."Object Text")) then don't try to update the Text, module probably open "read"

-Louie

Re: Displaying text or objects from one module to the other using links
djs1 - Wed Nov 13 13:45:55 EST 2013

llandale - Wed Nov 13 13:41:40 EST 2013

Looks like GregM posted while I was typing.  Did his thread resolve your issue?

While you CAN use Layouts/Attr-DXL to modify attributes I think it poor practice.  But if you do don't forget:

  • if (!canModify(obj."Object Text")) then don't try to update the Text, module probably open "read"

-Louie

Yes this tread resolved my issue.

I will keep in mind about your comment Louie.

Thanks