Page 1 of 1

unpicking tests in letters

Posted: Wed Mar 13, 2019 11:25 am
by danny
alright, when we have a really complicated letter template with lots of tests in it and they are all nested together
is there a way to see which ELSE END belongs to which test? can u get word to show u a code or something that links the elses and ends to their test?
we want to remove one of the tests but cant tell which else and end belong to which test

thx

Re: unpicking tests in letters

Posted: Wed Mar 13, 2019 2:50 pm
by revellbikes
Best way I've found is colour code the IF ELSE END's the same.

You can add formatting in Word aswell to make the IF ELSE ENDS highlighted all the same colour too.

But to answer your question - use a colour coding system, unless anyone has other solutions - I'm all ears :D

Re: unpicking tests in letters

Posted: Wed Mar 13, 2019 3:06 pm
by danny
thanks that helps point them out if someting has not gone wrong but we have a letter that has been cut and pasted loads and all the else ends are muddled up and the doc is broken

are the ELSE ENDS actually linked to the test that they were created with or are they just a generic else end that doesnt matter where you use it so long as you always have enough ENDs then it will work out?

thx

Re: unpicking tests in letters

Posted: Wed Mar 13, 2019 5:57 pm
by revellbikes
The test must be added through the field selector. All sections of this test relate to each other. So you can't just copy and past ELSE END from one test elsewhere in the document.

I'm afraid in this case your options are to roll back the version of the document to the last known working version. Or re-add the tests making sure all aspects are kept together and not jumbled around or duplicated, colour coding to make it easier for the next developer.

Re: unpicking tests in letters

Posted: Thu Mar 14, 2019 10:16 am
by danny
got it ill start color coding them when i add them
cheers good idea ;-)

Re: unpicking tests in letters

Posted: Mon Apr 08, 2019 6:15 pm
by steve
just my 2p, but I'm not convinced that ELSE END fields in letter TESTS are linked to specific tests, so they could theoretically be mixed and matched. My guess is that the logic parser just binds the ELSE or END to the nearest preceding IF, just as in C

TL;DR:
tried swapping ELSES and ENDS around - document still worked.

Detail:
Looking at the underlying RTF for a letter template, all instances of ELSE and END are the same and could therefore be interchanged without consequence.

A further clue is that if you amend a TEST in WFM, then Proclaim points out that you must re-add the test if you change the description, which matches the finding above which points to Proclaim simply doing a field search for the trigger keywords \\* MERGEFORMAT

Here's an IF field RTF for a test called "Client Ni No exists"

Code: Select all

{\field
	{\*\fldinst 
		{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid11107446  COMMENTS IF.Client_Ni_No_exists \\* MERGEFORMAT }
    }
    {\fldrslt 
        {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid11107446 IF.Client_Ni_No_exists}
    }
}
the ELSE field:

Code: Select all

{\field
    {\*\fldinst 
        {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid11107446  COMMENTS ELSE \\* MERGEFORMAT }
    }
    {\fldrslt 
        {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid11107446 ELSE}
    }
}
and the END field:

Code: Select all

{\field
    {\*\fldinst 
        {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid11107446  COMMENTS END \\* MERGEFORMAT }
    }
    {\fldrslt 
        {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid11107446 END}
    }
}
The \rtl \af \ltr \insrsid just relate to reading direction, font and session in which the edit was made.
The \fldinst and \fldslt are used to control the visibility of text relating to the field (toggle field codes and you'll see the "COMMENTS ELSE \\* MERGEFORMAT)

These were extracted from a sample letter template with a pair of nested tests, and the ELSE/END blocks were identical.
Unless there is some cleverness embedded in the OLECF of the Word doc then I don't see why moving ELSE and ENDS around would break a template.

I tested by creating a sample letter with a pair of nested tests:
IF.Test1 textiftest1true ELSE textiftest1false IF.Test2 test1false_test2true ELSE test1false_test2false END END

Perhaps a crude test, but swapping the two ELSE around and the document still merged correctly, and produced identical RTF within the .doc file itself.

If this is the case, then decompiling massive documents with many nested IFs should be a bit more straightforward, and it should be straightforward to make a small program to add a comment to text in a template so that a mousehover shows which tests apply to the text under cursor.

Re: unpicking tests in letters

Posted: Tue Apr 09, 2019 6:11 am
by revellbikes
Interesting findings Steve!

Ive had to deal with many 'broken' letters in my time and I've only ever been able to fix by manually cutting all pages out and adding pages or sections back in at a time. Finding the page or section that causes it to fail when produced in MCH, then re-adding those tests.

In your controlled test, did you CRTL+X a test then CTRL + V elsewhere or drag them around? There must be something that causes some different behaviour so that these ELSE ENDS lose their formatting?

I'd also welcome repeating the test on an older document, one with perhaps with 50+ tests across 20 pages to see if you get the same behaviour :)

Re: unpicking tests in letters

Posted: Tue Apr 09, 2019 9:06 am
by steve
Hi,
I cut and paste the ELSE using CTRL-X and CTRL-V
I agree it needs more testing on a bigger document, not something I have time for at the moment.
Wonder if any Eclipse technical staff out there lurking can shed light?
Toggling field codes on a broken document might just be sufficient to highlight any broken mergefields, although I have a feeling that 'broken' documents actually work perfectly (from the point of view of IF-ELSE-END parsing), just not as intended!