Page 240 - DCAP408_WEB_PROGRAMMING
P. 240

Web Programming




                    Notes          end  sub
                                   </script>




                                     Notes  We cannot use the ASP script delimiters (<% and %>) to insert scripts in the Global.asa
                                     file, we will have to put the subroutines inside the HTML <script> tag.

                                   9.6 # include

                                   The #include directive tells the preprocessor to treat the contents of a specified file as if those
                                   contents had appeared in the source program at the point where the directive appears. You can
                                   organize constant and macro definitions into include files and then use #include directives to
                                   add these definitions to any source file. Include files are also useful for incorporating declarations
                                   of external variables and complex data types. You need to define and name the types only once
                                   in an include file created for that purpose.
                                   #include    “path-spec”
                                   #include    <path-spec>
                                   The path-spec is a filename optionally preceded by a directory specification. The filename must
                                   name an existing file. The syntax of the path-spec depends on the operating system on which the
                                   program is compiled.
                                   Both syntax forms cause replacement of that directive by the entire contents of the specified
                                   include file. The difference between the two forms is the order in which the preprocessor searches
                                   for header files when the path is incompletely specified.

                                     Syntax Form          Action

                                     Quoted form          This  form  instructs  the  preprocessor  to  look  for  include  files  in  the
                                                          same directory of the file that contains the#include statement, and then
                                                          in  the  directories  of  any  files  that  include  (#include)  that  file.  The
                                                          preprocessor then searches along the path specified by the /I compiler
                                                          option,  then  along  paths  specified  by  the  INCLUDE  environment
                                                          variable.
                                     Angle-bracket form   This  form  instructs  the  preprocessor  to  search  for  include  files  first
                                                          along  the  path  specified  by  the  /I  compiler  option,  then,  when
                                                          compiling  from  the  command  line,  along  the  path  specified  by  the
                                                          INCLUDE environment variable.

                                   If the filename  enclosed in  double quotation marks is an incomplete  path specification,  the
                                   preprocessor first searches  the “parent”  file’s directory. A parent  file is  the file containing
                                   the #include directive.  For  example,  if  you  include  a  file  named file2 within  a  file
                                   named file1, file1 is the parent file.
                                   Include  files can  be “nested”;  that  is,  an #include directive  can appear in  a file named  by
                                   another #include directive.


                                          Example: File2, above, could  includefile3. In this case, file1 would still be the  parent
                                   of file2 but would be the “grandparent” of file3.

                                   When include files are nested and when compiling from the command line, directory searching
                                   begins with the directories of the parent file and then proceeds through the directories of any






          234                               LOVELY PROFESSIONAL UNIVERSITY
   235   236   237   238   239   240   241   242   243   244   245