Topic
  • 12 replies
  • Latest Post - ‏2013-11-13T18:45:55Z by djs1
djs1
djs1
7 Posts

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

‏2013-11-12T17:04:24Z |

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? 

  • GregM_dxler
    GregM_dxler
    166 Posts

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

    ‏2013-11-12T18:45:51Z  

    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

    Updated on 2013-11-12T18:50:31Z at 2013-11-12T18:50:31Z by GregM_dxler
  • llandale
    llandale
    3035 Posts

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

    ‏2013-11-12T18:47:51Z  

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

  • djs1
    djs1
    7 Posts

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

    ‏2013-11-12T19:03:39Z  

    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()

  • djs1
    djs1
    7 Posts

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

    ‏2013-11-12T19:46:39Z  
    • llandale
    • ‏2013-11-12T18:47:51Z

    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()

  • GregM_dxler
    GregM_dxler
    166 Posts

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

    ‏2013-11-12T20:51:43Z  
    • djs1
    • ‏2013-11-12T19:03:39Z

    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
     

  • djs1
    djs1
    7 Posts

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

    ‏2013-11-13T13:17:37Z  

    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

  • GregM_dxler
    GregM_dxler
    166 Posts

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

    ‏2013-11-13T13:32:35Z  
    • djs1
    • ‏2013-11-13T13:17:37Z

    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

  • djs1
    djs1
    7 Posts

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

    ‏2013-11-13T13:53:39Z  

    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.

  • GregM_dxler
    GregM_dxler
    166 Posts

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

    ‏2013-11-13T14:06:53Z  
    • djs1
    • ‏2013-11-13T13:53:39Z

    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.

  • djs1
    djs1
    7 Posts

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

    ‏2013-11-13T18:07:16Z  

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

    Thank you very much, your suggestions worked perfectly. 

    Sincerely,

     

    Dan

  • llandale
    llandale
    3035 Posts

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

    ‏2013-11-13T18:41:40Z  

    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

  • djs1
    djs1
    7 Posts

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

    ‏2013-11-13T18:45:55Z  
    • llandale
    • ‏2013-11-13T18:41:40Z

    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