Evaluation expression with multiple lines in results

I’m trying to put an evaluation expression in an HTML printer template for results based on payment amount. It would be nice to do this on multiple lines and just insert the block I want in between but I can’t get the expression to work when I do a breakline. Not sure its possible, just wondering if anyone has been successful? For example:

[={1}>2?
<table><tr>
<td>blah blah blah</td>
<td>blah blah blah</td>
</tr></table>
:
<table><tr>
<td>blah blah blah</td>
<td>blah blah blah</td>
</tr></table>
]

I’ve tried quotes, underscores at the end of lines, etc… Trying to show different tip amounts based on payment amount.

the [=] expressions don’t work with multi-lines, unfortunately.

If you’re looking to just display suggested tips try this and then wrap each line with whatever formatting you need:

10% - $[=F((TN('{PAYMENT TOTAL}')*.10),'#,#0.00')]
15% - $[=F((TN('{PAYMENT TOTAL}')*.15),'#,#0.00')]
20% - $[=F((TN('{PAYMENT TOTAL}')*.20),'#,#0.00')]

Yep, already doing that, but was looking to do a minimum recommended tip with adjusting the amount of recommended options. It would just be easier if we could do multiline expressions. No bother, it’ll still work.

What about something in a script to call

function someFunctionName(number)
{
    var rText = '';
    if (number > 2)
    {
        rText += '<table><tr>';
        rText += '<td>blah blah blah</td>';
        rText += '<td>blah blah blah</td>';
        rText += '</tr></table>';
        
        return rText;
    }
    else
    {
        rText += '<table><tr>';
        rText += '<td>blah blah blah</td>';
        rText += '<td>blah blah blah</td>';
        rText += '</tr></table>';
        
        return rText;
    }
}

That’s an option that I considered. It’s about the same amount of work. I think I’ll end up evaluating a single section of the table for recommended tip and that’s should keep it manageable. It not it will end up being a script.

Wouldnt having it all in one line work though?

[='{1}'>2? '<table><tr><td>blah blah blah</td><td>blah blah blah</td></tr></table>' : '<table><tr><td>blah blah blah</td><td>blah blah blah</td></tr></table>' ]

Yes, however keeping it formatted in the editor is preferred. There is 4 lines in the table all with two separate calculations on each line. It’s really not a problem, just wondering if there was a simple way to have run on lines within the expression.

What I do use the conditional block to insert an HTML comment tag if I want the item hidden…

[= '{1}' > 2 ? '<!-- Hide this stuff' : '']
<table><tr>
<td>This will be hidden if {1} is > 2</td>
</tr></table>
[= '{1}' > 2 ? '-->' : '']
1 Like

Thats an interesting idea. I’ll give that a try.

This worked great @mjb2000, much appreciated. The only issue I had is trying to evaluate “greater than” >. It keep crashing SambaPOS. Less than “<” works fine. Its likely because my block is within the REPORT SQL DETAILS. I ended up flipping the values and just using less than and less than or equal to.

[=3<TN('{1}')? '<!-- ' \: ' ']
<table>
<tr>
<td width=30><span style='font-size\:20px;'>&#10063;</span></td>
<td width=100>Tip\: $1.00 </td>
<td width=100>Total\: $[=F(1 + {1},'0.00')]</td>
</tr>
<tr>
<td width=30><span style='font-size\:20px;'>&#10063;</span></td>
<td width=100>Tip\: $2.00 </td>
<td width=100>Total\: $[=F(2 + {1},'0.00')]</td>
</tr>
<tr>
<td width="30"><span style='font-size\:20px;'>&#10063;</span></td>
<td width="100" align="center">$&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;</td>
<td width="100" align="center">$&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;</td>
</tr>
<tr>
<td width="30"><span style='font-size\:20px;'>&zwnj;</span></td>
<td width="100" align="center">Custom Tip</td>
<td width="100" align="center">Total</td>
</tr>
</table>
[=3<TN('{1}')? ' -->' \: ' ']

[=TN('{1}')<=3? '<!-- ' \: ' ']
<table>
<tr>
<td width=30><span style='font-size\:20px;'>&#10063;</span></td>
<td width=30 align=left>15%</td>
<td width=80>Tip\: $[=F(Math.round((TN('{1}') * 0.15)*100)/100,'0.00')] </td>
<td width=80>Total\: $[=F(Math.round((TN('{1}') * 0.15)*100)/100 + {1},'0.00')]</td>
</tr>
<tr>
<td width=30><span style='font-size\:20px;'>&#10063;</span></td>
<td width=30 align=left>18%</td>
<td width=80>Tip\: $[=F(Math.round((TN('{1}') * 0.18)*100)/100,'0.00')]</td>
<td width=80>Total\: $[=F(Math.round((TN('{1}') * 0.18)*100)/100 + {1},'0.00')]</td>
</tr>
<tr>
<td width="30"><span style='font-size\:20px;'>&#10063;</span></td>
<td width="30" align=left>20%</td>
<td width="80">Tip\: $[=F(Math.round((TN('{1}') * 0.20)*100)/100,'0.00')]</td>
<td width="80">Total\: $[=F(Math.round((TN('{1}') * 0.20)*100)/100 + {1},'0.00')]</td>
</tr>
<tr>
<td width="30"><span style='font-size\:20px;'>&#10063;</span></td>
<td width="30" align=left>25%</td>
<td width="80">Tip\: $[=F(Math.round((TN('{1}') * 0.25)*100)/100,'0.00')]</td>
<td width="80">Total\: $[=F(Math.round((TN('{1}') * 0.25)*100)/100 + {1},'0.00')]</td>
</tr>
<tr>
<td width="30"><span style='font-size\:20px;'>&#10063;</span></td>
<td width="100" align="center">$&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;</td>
<td width="100" align="center">$&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;&#95;</td>
</tr>
<tr>
<td width="30"><span style='font-size\:20px;'>&zwnj;</span></td>
<td width="100" align="center">Custom Tip</td>
<td width="100" align="center">Total</td>
</tr>
</table>
[=TN('{1}')<=3? ' -->' \: ' ']
1 Like