Skip to main content

CSP Elements: Methods

CSP scripts allow you to add methods to your CSP page. These methods can be invoked, by CSP expressions for example, from anywhere on the page. Define a method using script tags. Values assigned to the method, arguments, and returntype attributes determine, respectively, the method's name, argument list, and return type. The code lying between the tags becomes the method body.

Add the code shown below to your MySamplePage.CSP between <body> and </body>. The code between the <script></script> tags defines a method that returns “true” if it is passed an even integer and returns “false” otherwise. The code between <p> and </p> invokes the method in a runtime expression. You can remove any other code from between <body> and </body>.

<body>
<p>11 is #(..OddEvenTest(11))#</p> <!--Invoke Method-->
<script language="cache" method="OddEvenTest" arguments="val1:%Integer" 
returntype="%String">
  If (val1#2=0) { quit "even" }
  Else {quit "odd"}
</script>
</body>

Click View —> Web Page to view MySamplePage.CSP in a Web browser.

generated description: scriptmethod20142

Note:

Class methods of other classes can be invoked using the standard ObjectScript syntax for invoking class methods: ##class(PackageName.ClassName).MethodName.

FeedbackOpens in a new tab