Not sure if this is a bug, I am probably just doing this wrong. Eventually, I want to check two values and if either of them are not 0 then I want to write some text as well as the answer to a calculation.
To keep the example simpler, I have replaced some long tags and maths with simple number and equations, but the problem still exists:
Very strangely, if I incorrectly comment out the lines, and don’t leave the space after the “–” then the preview in the template editior shows correctly (although the actual printout from the printer is incorrect).
Sorry, I should have siad - deleting the other statements also leads to the weird output.
Commenting properly and deleting produces the same, strange output.
What’s reallty weird is the commenting incorrectly leads to the correct output within the template editor preview. By “incorrect commenting” I mean (Note the lack of space after the comment markers)…
You should use {CALL:X} script.
In printer template square bracket use to validate if it zero value then display nothing as well. So, this would cause parsing error.
I am looking in to this, so is the idea that I would put the mathematics that I want calculated in an external function and call that function using CALL?
Is there any way to handle this all within the printer template without creating these external functions?
You cannot nest [=expressions], and there should be no need to do so. If you think you have some logic that requires that complexity, then you need to make a JS script containing a function and invoke it via {CALL:handlerName.functionName(pa,ra,me,te,rs)}.
You can also wrap those in more [brackets] as @sukasem shows if you are trying to avoid printing blank lines. What that does is evaluate the inner-most bracket content, and if blank or zero, then the entire content of the outer-most bracket content is not printed.
Commented lines in a Template require a space after the --
Thinking with my JS hat on, I had tried what you suggested, and figured, since we are already in a JS expression there was no need to start another one, but it just doesn’t seem to work in the way you have set out your examples, and I couldn’t think why.
With a reasonable background in JS, my first approach was to do what you are suggesting, but when I put it in to a template it doesn’t show anything. Any ideas why (I would prefer to do it this way because for me, it’s much more understandable).
But thats the thing, it’s not working as I’d expect. Perhaps because the result of the math is not a string, but I also tried toString(10-5), but that didn’t work either.
I think the issue is because we are trying to add a string to an intefer?