Skip to main content

Adding MVBasic Code — CSP Scripts

CSP can use MVBasic routines to generate dynamic CSP content. There are several different approaches for including MVBasic routines in a CSP page. One approach is to use CSP Scripts — blocks of code between <script></script> tags. Each time that Caché generates the page, the code in the script executes. Here are the steps:

  1. Open FirstPage.CSP in Studio.

  2. Add the following directive at the very top of the file. The directive sets the default “page language” of the CSP page to MVBasic

    <%@page language="mvbasic"%>                                   
  3. Replace any code currently between the <body></body> tags with the following. Note that both the language and runat attributes are required by the <script> tag. Their values must by “mvbasic” and “server” respectively.

    <script language="mvbasic" runat="server">
    PRINT "<h2>Welcome to CSP!</h2>"
  4. The FirstPage.CSP code looks like this

    generated description: studiosavefirstcsp2 20101

  5. Click Build–>Compile to recompile FirstPage.CSP

  6. Click View–>Web Page to see the new page:

    generated description: viewfirstcsp3 20142


To learn more about CSP scripts, read CSP Elements: Scripts in the CSP QuickStart Tutorial.

FeedbackOpens in a new tab