Use DXL to copy Bold/Italic text from one module to another issue

I have created a configuration module which consists of plain text, bolded text, and italic text.

I have not been successful in getting the configuration module data copied over into another module. I can read the object text, and then copy this to the other module, but bold and italic do not appear as expected.

Does anyone have any suggestions?

Thank you.

The code that I use follows:
 

void dumpAllInfo(RichText rt)
{
        print "***********New chunk:\n"
        print "text:" rt.text ": "
        print "bold:" rt.bold ": "
        print "italic:" rt.italic ": "
        print "underline:" rt.underline ":\n"
        print "strikethru:" rt.strikethru ": "
        print "superscript:" rt.superscript ": "
        print "subscript:" rt.subscript ": "
        print "charset:" rt.charset ":\n"
        print "newline:" rt.newline ": "
        print "last:" rt.last ":\n"
        // new in 6.0
        print "isOle:" rt.isOle ": "
        print "indent:" rt.indentLevel ": "
        print "bullet:" rt.isBullet ": "
        print "bulletStyle:" rt.bulletStyle ": "
        print "isUrl:" rt.isUrl ":\n"
}
void dumpAllParagraphs(string s)
{
        RichTextParagraph rp
        RichText rt
        for rp in s do
        {
                print "****New paragraph\n"
                print "text:" rp.text ":\n "
                print "indent:" rp.indentLevel ": "
                print "bullet:" rp.isBullet ":\n"
                print "bulletStyle:" rp.bulletStyle ":\n"
                for rt in rp do
                {
                        dumpAllInfo rt
                }
        }
}
string GetTemplate()
{
        // read in configuration module which contains mixture of Bold and italic text.
        mTemplate = read(strReviewTemplate,false)
        string strOHead
        int nHeaderType = 0
        string strObjectText
        string strTemp
        Module mTemplate
        Object oTemplate
 
        for oTemplate in mTemplate do
        {
                strOHead = oTemplate."Object Heading"
                if (nHeaderType == 1)
                {
                        strObjectText = richText oTemplate."Object Text"
                } // end if (nHeaderType == 1)
                if (strOHead == "Review") // read current header
                {
                        nHeaderType = 1
                } // end if (strOHead == "Review") // read current header
        } // end for o in mTemplate do
        //Calling dumpAllParagraphs shows the correct text that should be bold, as well as italic.
        dumpAllParagraphs(strObjectText
        return(strObjectText)
} // GetTemplate()
 
//main
Module m
Object o
 
for o in m do
{
        ...
        //When the word Review is found in a header, call GetTemplate
        string strCombo = GetTemplate()
        o."Object Text" = strCombo
        break
        // copied data does not appear as expected
}

Gedinfo - Fri Mar 15 16:56:32 EDT 2013

Re: Use DXL to copy Bold/Italic text from one module to another issue
llandale - Sat Mar 16 13:25:09 EDT 2013

Change line 75:
  • o."Object Text" = strCombo
to:
  • o."Object Text" = richText(strCombo)

-Louie

On other news...

[] GetTemplate() seems odd to me. Once you find a "Review" heading, then you get (and dump) the Object text of all the rest of the objects. I notice that "stObjecText" houses only the LAST object in the module, and you return that value. That one value is set to every object in the orignal module.

I wonder if line 54:
  • strObjectText = richText oTemplate."Object Text"
is the object you are looking for, and needs to be followed by a "break" statement.

I wonder also if you should instead do this at line 54:
  • strObjectText = richTextWithOLE oTemplate."Object Text"

[] I wonder if "GetTemplate" should accept a "Heading" string value, in this case "Review" and be coded to presume that it will retrieve the Objecgt Text that comes in the object AFTER that heading. Your bottom loop likewise would look for that same heading before calling GetTemplate.

[] Seems to me that line 46:
  • Module mTemplate
should come before line 41:
  • mTemplate = read(strReviewTemplate,false)
or merged:
  • Module mTemplate = read(strReviewTemplate,false)

[] You seem to be missing some code
  • line 67:
    • Module m = current
  • Line 62 needs closing brace:
    • dumpAllParagraphs(strObjectText)
[] I dare to criticise style. line 42 "nHeaderType" could be a boolean "ReviewFound"
[] Consider adding this function; then call it instead of printing all the values:
  • void DumpIfTrue(string Label, bool DumpIt)
  • { if (DumpIt) then print Label ":\t" DumpIt "\n"
  • }
  • Then change this at line 5
    • print "bold:" rt.bold ": "
  • to this:
    • DumpIfTrue("bold", rt.bold)
  • This will only print RTP and RT features that are true and make your print out far smaller and far easier to read.

Re: Use DXL to copy Bold/Italic text from one module to another issue
Gedinfo - Tue Mar 19 09:10:20 EDT 2013

Thanks Louie!