Skip to main content

CSP Elements: Expressions

CSP expressions allow you to insert ObjectScript (or Caché Basic) expressions into your CSP page. These expressions are evaluated either at runtime, #(expr)#, or compile-time, ##(expr)##, and the result is added to the HTML returned to the client.

Add the text and CSP elements shown below between the <body></body> tags on MySamplePage.CSP. You can remove all other code from between <body> and </body>

<p>Runtime is: #($ztime($piece($h,",",2)))#</p>
<p>Compile-time is: ##($ztime($piece($h,",",2)))##</p>

When evaluated, both of the above expressions return the “current” time. However, the two expressions are evaluated at different stages in the page lifecycle, so the resulting times differ. The first expression, #(expr)#, is a runtime expression. It is evaluated when the CSP page executes. The second expression, ##(expr)##, is a compile-time expression. It is evaluated when the page class is compiled. Since execution comes after the compilation, the first time is always later than the second.

First, click Build —> Compile to compile the page. Then, click View —> Web Page to view MySamplePage.CSP in a Web browser. Verify that the first timestamp is later than the second:

generated description: expressions20142

FeedbackOpens in a new tab