Written by

Manager, Application Services at InterSystems
Question Ben Spead · Apr 25, 2023

How to escape ')#' inside a CSP Runtime Expression?

I have a csp page that is using embedded Runtime Expression (https://docs.intersystems.com/ens201817/csp/docbook/Doc.View.cls?KEY=RC…) and within that expression I am using a $data() modulo 2 to look for root-level data elements (https://docs.intersystems.com/ens201817/csp/docbook/Doc.View.cls?KEY=RC…).

E.g:

#($select($data(^ImportantFlag)#2:"Important!",1:"Normal"))#

However, my modulo sign (#) after the $data() call is seen as the ending tag for the runtime expression resulting in a broken compilation.

Does anyone know if there is a way to escape )# or just # in a CSP Runtime Expression?  Or do I need to abandon the elegance of the approach and actually check for a return value of 1 or 11 to ensure top level data?  

Product version: IRIS 2022.1

Comments

Gertjan Klein · Apr 25, 2023

A simple space before the modulus operator will fix this:

#($select($data(^ImportantFlag) #2:"Important!",1:"Normal"))#

(Note that I needed to add a closing brace for the $Select as well.) If you wish, you can add a few more spaces for readability. 😉

0
Ben Spead  Apr 25, 2023 to Gertjan Klein

Thank you @Gertjan Klein - that did it!  (note, I fixed the missing ) in my example ... obviously I wrote that in my browser and not my IDE ;) )

0
Yaron Munz · Apr 25, 2023

if you encounter another situation that you cannot add a space before the # you can do:

<server>
W #($select($data(^ImportantFlag)#2:"Important!",1:"Normal"))#
</server>
0