|
APG Script Syntax Reference |
|
See Also: |
Executes/includes the contents of another APG script.
<!-- #INCLUDE APG=PATH -->
| Attribute | Description |
| APG=PATH | Necessary. Specifies the relative or absolute path to the include file. If the path is relative, the path is followed from the APG script containing the #include statement. If the path contains spaces, the path should be surrounded by quotes. |
The #include directive is equivalent to inserting the contents of the include file at the location of the #INCLUDE tag. The included file is treated as an APG script: script with global scope is executed; content with global scope is written to the output stream; procedures and functions are compiled.
It is important to note that the <!-- #INCLUDE APG=path -->tag can only be used within content blocks. Since script blocks are compiled by a script engine, using the #INCLUDE tag within a script block will cause the script engine to generate a syntax error.
Below is an example using #INCLUDE. The file std.inc contains two procedures; RenderHTMLHeader and RenderHTMLFooter:
<%#
'-------------------------------------------------------
' std.inc
'
' Standard HTML header and footer stuff
' Requires gTitle to be defined.
'
Sub RenderHTMLHeader(strTitle)
#%> <!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN"">
<html>
<head>
<title> <%# =strTitle #%> </title>
</head>
<body bgcolor=""#EEEEEE"" topmargin=""0"" leftmargin=""0"" LINK=""#0080FF"" VLINK=""#0080FF""> <H2>
<%# Output.Write(strTitle) #%>
</H2> <%#
End Sub
Sub RenderHTMLFooter #%>
</body>
</html> <%#
End Sub #%>
The APG script hello.apg includes std.inc:
<!-- #include apg = "std.inc" -->
<%#
'-------------------------------------------------------
' hello.apg
'
Sub Main
Output.Filename = "hello.htm"
Call RenderHTMLHeader("Hello World!")
#%>
Hello World Body Text
<%#
Call RenderHTMLFooter
End Sub
#%>
When test.apg is run, the following hello.htm file is created:
<!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN"">
<html>
<head>
<title> Hello World! </title>
</head>
<body bgcolor=""#EEEEEE"" topmargin=""0"" leftmargin=""0"" LINK=""#0080FF"" VLINK=""#0080FF""> <H2>
Hello World!
</H2>
Hello World Body Text
</body>
</html>
which appears like this in the browser:
