Monday, March 22, 2010

How to Use the #include Directive Here is a file called "mypage.asp": Words of Wisdom:

The time is:

Here is the "wisdom.inc" file: "One should never increase, beyond what is necessary, the number of entities required to explain anything." Here is the "time.inc" file: <% Response.Write(Time) %> If you look at the source code in a browser, it will look something like this:
Words of Wisdom:

"One should never increase, beyond what is necessary, the number of entities required to explain anything."
The time is:

11:33:42 AM
Syntax for Including Files To include a file in an ASP page, place the #include directive inside comment tags: or The Virtual Keyword Use the virtual keyword to indicate a path beginning with a virtual directory. If a file named "header.inc" resides in a virtual directory named /html, the following line would insert the contents of "header.inc": The File Keyword Use the file keyword to indicate a relative path. A relative path begins with the directory that contains the including file. If you have a file in the html directory, and the file "header.inc" resides in html\headers, the following line would insert "header.inc" in your file: Note that the path to the included file (headers\header.inc) is relative to the including file. If the file containing this #include statement is not in the html directory, the statement will not work.