Assigns a value to a named variable, enabling the value to be re-used.
<!-- #ICE [REPEAT] DECLARE=`[level.]variable_name=value` -->
The Ingres/ICE server extends the availability of variables over standard HTML variables. HTML variables must be passed as part of the invoking URI. A reference to the HTML variable is replaced by the actual text when Ingres/ICE parses the file.
Ingres/ICE variables are more convenient in that they are maintained by the server and are not part of the Ingres/ICE address. Also, Ingres/ICE variables cannot have their values altered by a user changing the value in the Ingres/ICE address (URI) within the browser window.
Parameters The following table lists the parameters used with the DECLARE keyword:
|
Parameter |
Description |
|
level |
The lifetime of the variable. The available choices are: n server—loaded when the Ingres/ICE server starts and available for use until the Ingres/ICE server is shut down. A server variable persists as long as the repository database is not deleted. n session—available for use while the Web user is logged in and has not timed out. n page—available for use anywhere within the document. Once the document has been passed back to the browser, the variable becomes invalid. |
|
variable_name |
The name of a variable. |
|
value |
The value assigned to the variable. |
Because all the variable lifetime values use the same name space, they are all accessed in the same way. For example:
:ServerVariable
:SessionVariable
:PageVariable
The declared variable may be used within a document by using it in an Ingres/ICE macro. Any variable can be used by preceeding its name with the colon (:), but you cannot have a session-level variable with the same name as a server-level variable. This is why it is a good idea to establish a naming convention such as that suggested in the Committing Transactions on the Home Page section of the “Creating Web Applications: A Worked Example” chapter.
REPEAT Option The REPEAT option allows the recursive parsing of macros. This allows multiple queries and macros to be embedded within a single macro. It must be used in conjunction with another macro option and has no meaning when used on its own.
Since the grave quote (`) and the colon (:) characters are used as delimiters, they must be duplicated when used with the REPEAT option. This option has the effect of disabling the delimiting effect when only one delimiter is used.
Note: The REPEAT option has to be used carefully with the DECLARE keyword. It implies that further macros must be resolved, the results of which will be used to DECLARE. It is possible to declare variables containing large strings or to issue a repeated declare that recurses and takes memory. All declared information will permanently reside in memory.
<!-- #ICE DECLARE=`page.myVar=static string` -->
<!-- #ICE DECLARE=`page.myVar=:anotherVariable` -->
<!-- #ICE DECLARE=`page.myVar=:anotherVariable +
static string` -->
<!-- #ICE DECLARE=`session.myVar=static string` -->
<!-- #ICE DECLARE=`session.myVar=:anotherVariable`
-->