Strings with curly brackets in templates

Curly brackets are special characters in templates. Also apostrophes are special.

If I send a string containing a single curly bracket from a template to a script SambaPOS freezes and I must terminate it.

Capture

Capture2

I believe that echo.echoString is not even been called. The problem might be SambaPOS trying to figure out an expression from:

‘{abc’

What can I do to be able to send brackets to a function from a template?

Yes that confuses parser. Maybe you can use a different unused character and replace it with { inside echoText function.

Hi Emre!

Yes I noticed it. It would be great if SambaPOS can throw a exception though. I circumvented the problem and I am not sending special characters any more but still I think the exception would help

Thanks

2 Likes

I understand why SambaPOS won’t always throw an exception on these types of formatting issues, reason is certain content may be entered by end users without knowledge of special characters, like product names, entity data, etc. If you throw an exception on any such error during printing a template, you end up it doesn’t print, whereas handling the exception and still printing is desired in most situations.

I would however suggest it would be good if the exceptions can be logged and retrieved somewhere, as I have had to deal with similar situations in the past and it’s not always easy to debug the template when no exception is thrown. Maybe a logging option? @emre

1 Like

SambaPOS will catch a bracket issue here and display a warning when you print preview it.

<C8>Text: {CALL:utl.echoText('{abc')}

However this is a valid syntax.

<C8>Text: {CALL:utl.echoText('{abc}')}

SambaPOS will render {abc} to nothing as there is no registered handler for abc. I won’t attempt to validate tags as they may contain expressions and will probably generate false warnings for some cases.

3 Likes