DSP Tutorial Step 21
Fetching Preprocessor Symbols
The fetch directive allows a DSP page to use the value
of a preprocessor symbol inside Delphi code. Specifically, it assigns
the value of a preprocessor symbol to a Delphi expression. The syntax
of this directive is as follows:
<@% fetch into="Delphi-variable" from="expr" %>
Notes:
Use this directive to fetch the value of a symbol into a Delphi variable.
For example, assuming that the Version symbol has a value of 5,
then the following directive...
<%@ fetch into="n" from="version" %>
Generates the following code:
n := 5;
The value of the into attribute may be any valid Delphi expression,
which will appear on the left-hand side of the assignment operator.
The value of the from attribute is any expression that could be
used in the define directive. If the resulting value of
this expression is a string, it will appear quoted in the generated code.
For example,
<%@ define host="'MyComputer'" %>
<%@ fetch into="msg" from="host + '.com'" %>
Generates the following code:
msg := 'MyComputer.com';
This tutorial example illustrates this technique.
| Contents of Page21.dsp |
<html>
<head>
<title> Tutorial Step 21 </title>
</head>
<body>
<%@ define host="'MyComputer'" %>
<%@ begin nested %>
<%
var
msg: string;
%>
<%@ end nested %>
<%@ fetch into="msg" from="host + '.com'" %>
The host is <%| msg %>.
</body>
</html>
|
|
Copyright © 2002 Dimeric Software L.L.C.
|