Categories > OpenTBS with ODT >

if-then-else statements seem to be completely ignored in .odt template

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: dmyers
Date: 2013-01-25
Time: 17:04

if-then-else statements seem to be completely ignored in .odt template

I have the following section in an odt template:

[var.data.ADM_EA_PAR; if [val]=="E1"; then "show text for E1"; if [val]=="E2"; then "show text for E2"; if [val]=="E3"; then "show text for E3"; if [val]=="E4"; then "show text for E4"; else ""]

The field is being merged properly, but the if statements are completely ignored. Instead of displaying the appropriate 'then' message, it simply shows the value of 'data.ADM_EA_PAR'.

Can anyone shed some light on what is wrong?

Thanks
By: dmyers
Date: 2013-01-25
Time: 20:14

Re: if-then-else statements seem to be completely ignored in .odt template

Ok, after messing with it some more, I found it is related to a problem I've been seeing where TBS fields are no longer recognized if they have been modified. This means that if I have a field [var.data.ADM_EA_PAR] and I change it to [var.data.ADM_FNAME], then I would get the following error message:
TinyButStrong Error in field [var.data.This message can be cancelled using parameter 'noerr'.

The only way around it is to completely remove the [...] text and rewrite it. I don't know if this is a bug with TBS or libreoffice doing something strange when saving the document.
By: Sarah
Date: 2013-01-25
Time: 20:23

Re: if-then-else statements seem to be completely ignored in .odt template

I don't know if this will help, but var in place of onshow or ondata is deprecated. Have you tried using:

[onshow.data.ADM_EA_PAR; if [val]=="E1"; then "show text for E1"; if [val]=="E2"; then "show text for E2"; if [val]=="E3"; then "show text for E3"; if [val]=="E4"; then "show text for E4"; else ""]

(or onload or ondata if that works better for you)

Secondly, if LibreOffice is like MS Word, it likely inserts extra tags inside of the TBS tag whenever you edit (in order to help the GUI return to your previous place when you hit undo). It may also insert extra tags if there are spelling or grammar errors there. Removing the tag and starting again would clear out these extra tags, but every time you edit them again the same will occur. I wrote a tip about removing these tags in MS Word which may be applicable: http://www.tinybutstrong.com/forum.php?thr=3072. Basically, if you are seeing any grammar or spelling issues, run your spell check and make sure you ignore any problems in TBS tags. This may help.

You can see the problems TBS is encountering when you get these errors by using $TBS->PlugIn(OPENTBS_DEBUG_XML_SHOW): http://www.tinybutstrong.com/plugins/opentbs/tbs_plugin_opentbs.html#debug