The real power in a CSP page is its ability to combine HTML with programming code. For example, take a basic CSP file that uses script to display the date and time.
<% @Language=VBScript %> <% Response.Write Now %>
<% @language=JavaScript %> <% Response.Write (Date().toString()); %>
If you've used ASP scripting, then this will look familiar. The script is always enclosed between the two tags <%
and %>
. The lines Response.Write (Now
) and Response.Write(Date)
indicate that the current date should be output. Response.Write
allows output, and the functions Now
(VBScript) and Date
(JavaScript) each return the date and time.
Paste this example into a text file, save it with a .csp extension, and then copy it to the WCS. When you reference the CSP page in your web browser, you should
see something like this:
Note: The date and time format depends on the scripting language and regional settings. This example uses VBScript and English settings.
If you look at the source, you'll notice that it looks exactly the same: only the result of the script was returned. Everything between the <%
tags is evaluated on the server.
Now change the script to read:
<% @Language=VBScript %> The time is:<%
Response.Write "<B>" & Now & "</B>
" %>
<% @language=JavaScript %> The time is: <% Response.Write ("<B>" + Date().toString() + "</B>"); %>
Save your changes and refresh the page in your browser. The result might look something like this:
The time is: 4/5/2000 10:49:51 AM
The source for the page will read:
The time is: <B>4/5/2000 10:49:51 AM</B>
Note: The date and time format depends on the scripting language and regional settings. This example uses VBScript and English settings.
You can see that in a CSP page, you can write normal HTML and insert the script wherever you want. Within the script, you can add HTML tags with quotation marks around them (for example, "<B>"), and, in VBScript, you can concatenate the script and the tags using an ampersand (&); to concatenate strings in JavaScript, use +.
Now that you can use basic CSP scripting, you can start using the Crystal Enterprise SDK to write a custom Enterprise desktop.
Note: This documentation does not cover all aspects of the VBScript and JavaScript languages. Full references for these are available on the web or in printed references.
For a complete reference of the objects available for use when writing Crystal Server Pages, see the CSP Reference.
Crystal Decisions, Inc. http://www.crystaldecisions.com Support services: http://support.crystaldecisions.com |