Text display formula

I can’t understand why the following formula for a text display object isn’t working:
{«SurgeryBillings»} {«Consumables»}
${«MedicareRefund»}

{«SurgeryBillings»-«PrivateHospital»} {«PrivateHospital»}
${«FinaliseBillings»}

{«HospitalFees»} {«InHours»}
{«EmployeeAfterHours»/EmployeeAHR*100} {«OnCall»}

This has been automatically converted from a Panorama 6 programme, and the “Literal Text” option is selected. The result is an error message saying “Cannot subtract a number from text”. The problem is in the {«SurgeryBillings»-«PrivateHospital»} line. Both are definitely considered as numbers in the database. Interestingly, its quite happy with dividing one Field by another lower down in the same formula: {«EmployeeAfterHours»/EmployeeAHR*100}.
Is this a programme glitch or am I (as is so often the case) missing some fundamental issue?

That looks like a bug to me, but I think I’ve found a workaround. Try changing

{«SurgeryBillings»-«PrivateHospital»}

to

{str(«SurgeryBillings»-«PrivateHospital»)}

or to

{pattern(«SurgeryBillings»-«PrivateHospital»,"#.##")}

After further testing, it appears that you could also use

{(«SurgeryBillings»-«PrivateHospital»)}

It acts like there is an implied concatenation operator before SurgeryBillings which takes the same precedence as subtraction. SurgeryBillings is being converted to text, and concatenated with the preceding text, and then it tries to do the subtraction. Adding the parentheses makes it do the subtraction first.

The division and multiplication in the line further down is working, because those operators take precedence over concatenation.

Thank you Dave! You have zeroed in on the exact problem, and made it super easy for me to make a fix. In the next version of Panorama, this will work without needing the parentheses (because Panorama now adds parentheses on it’s own).

For anyone wondering about the exact why of this, consider this Text Display literal text:

Profit is {Price-Cost}

To display this, Panorama converts this to a regular formula, which is this:

{Profit is }+Price-Cost+{}

However, {Profit is }+Price results in a string, which then produces an error when you try to subtract Cost.

I have changed Panorama so that now the internally generated formula is.

{Profit is }+(Price-Cost)+{}

which works. In the meantime, you’ll have to add the parentheses yourself until the next version is available.

Thankyou. That gets me out of trouble. I would never have figured out what was happening….

Funny thing. I was going to convert it all to the {pattern(«SurgeryBillings,"$#,.##”)}etc format as soon as I’d figured out why the other problem wasn’t working!!!

PS updated Panorama X is really getting there. When I first tried to convert this programme from Panorama 6 it had red ’not working’ signs on every formula and the forms were crazy. This time, I’ve got a functional programme, with just a few changes needing to be made (although I’m changing a lot more, to make use of the new features and/or my improved knowledge of what can be achieved)
Thanks