C++ Server Pages Syntax
| Syntax: CSP scripts are blended HTML/C++ language scripts. Within a CSP script the, C++ code resides inside the “<% …(c++ code)… %>” tags and HTML outside those tags. For example: <p>This is HTML code.</p> <% // This is C++ code int x = 0; %> As with other similar scripting languages, you can directly evaluate a C++ expression and output it to the client by using the "<%= expression %>" tag. For example: <p>The value of the variable is:<%=MyVariable%></p> Note that when you use the evaluation tag, there must be no whitespace between the opening symbol "<%" and the symbol "=". Also, inside this tag you must type a C++ expression and not a C++ statement, which means that you must not use the statement terminating symbol ";". The intrinsic objects Response, Request, Session, Application, and Page are available for use in the C++ code. Besides the C++ code in the body of the script, there may be a need for global scope declarations, as well as initialization or cleanup code to be executed when a script is first executed or unloaded from the memory. The Global Scope section for C++ code is defined by using the tag "<%!global: ... (global scope C++ code) ...%>", or by simply using the tag "<%! ... (global scope C++ code) ...%>". For example: <%! // global scope code int iCount = 0; %> <% // body code ++iCount; %> <p> Hits since script was first loaded: <% // body code Response.Write( iCount ); %> </p> The Initialization section for C++ code is defined by using the tag "<%!onload: ... (initialization C++ code) ...%>". For example: <%! // global scope code int iCount; %> <%!onload: // initialization code iCount = 1; %> <% // body code ++iCount; %> <p> Hits since script was first loaded: <% // body code Response.Write( iCount ); %> </p> The initialization code is executed everytime the compiled binary (dll) of a CSP script is loaded in the memory. The intrinsic objects Page and Application are available for use in this section. The Clean Up section for C++ code is defined by using the tag "<%!onfree: ... (clean up C++ code) ...%>". For example: <%! // global scope code unsigned char* pMem; %> <%!onload: // initialization code pMem = new unsigned char [1024]; %> <%!onfree: // clean up code delete[] pMem; %> The clean up code is executed everytime the compiled binary (dll) of a CSP script is unloaded from the memory. The intrinsic objects Page and Application are available for use in this section.
Quick Overview | Online help home | Back
www.micronovae.com Copyright © 2002 - 2004 Micronovae Ltd