Dynamic Includes - Possible workaround? Critique?

Results 1 to 5 of 5

Thread: Dynamic Includes - Possible workaround? Critique?

  1. #1
    Cyanide_7 Guest

    Default Dynamic Includes - Possible workaround? Critique?

    I&#039d like to ponder a workaround of sorts for the ongoing plight of dynamic includes in ASP. From what I understand, includes are processed before the ASP script is parsed. Also, the workaround suggested by the FAQs suggests including predetermined files and nesting them in CASES so only one shows. The solution that I have found will dynamically include a variable source. BUT, the catch is that such a file cannot be further parsed... Well how bout I just show the code so as to make more sense:<BR><BR><BR>SUB include(inc_file)<BR>**Dim filesystem, textfile, filepath<BR>**filepath = Server.mappath(inc_file)<BR>**Set filesystem = Server.CreateObject("Scripting.FileSystemObject")< BR>**IF filesystem.FileExists(filepath) THEN<BR>****Set textfile = filesystem.OpenTextFile(filepath, 1)<BR>****Response.write textfile.ReadAll<BR>**ELSE<BR>****Response.w rite "File " & inc_file & " not found."<BR>**END IF<BR>END SUB<BR><BR><BR>Personally I have this traditionally included in some ASP pages and use them like so:<BR><BR><BR>file_name = Request.QueryString("filename")<BR>include(file_na me)<BR><BR><BR>Any thoughts? Suggestions? Any ideas on how to get the included file parsed if at all possible?!?<BR> Thanx - Cyanide_7

  2. #2
    SPG Guest

    Default RE: Dynamic Includes - Possible workaround? Critiq

    You&#039ve found a known method of importing page content -- and it&#039s good at and for that (much better than a case of #includes, yikes!). However, since the compiler only goes over the ASP line-by-freakin&#039-line once, you can&#039t effectively use this to import functions and such -- unless to go to the extra effort of using it to actually generate the .asp scripts to the disk...<BR><BR>All of this has been resolved in ASP 3.0 with the creation of server.execute, which can include files at run-time. (&#039bout bloody time...). Do a search for "IIS 5.0" for the articles.

  3. #3
    Join Date
    Dec 1969

    Default I avoid dynamic includes

    I include everything at the top of the page, after &#039option explicit&#039.<BR><BR>&#039everything&#039 is files that contain subroutines and functions that are likely to be used sitewide. <BR><BR>When I need a variable or a call to a COM object, etc, etc, I call it.<BR><BR>I think the notion of dynamic includes is a fallacy. If the code is modular, then you can &#039include&#039 as much of it as you want. Server will only process code that is specifically called. <BR><BR>Select case statements work fine, i&#039m sure, but making logic decisions that call entire files to be processed can&#039t be very efficient.<BR><BR>Correct me if i&#039m wrong...

  4. #4
    Join Date
    Dec 1969

    Default RE: Dynamic Includes - Possible workaround? Critiq

    Not to burst your bubble, but...<BR><BR>Your suggestion is the one given in several FAQ postings. I believe the one maintained for the Microsoft ASP newsgroups (by Bertrand and I always forget his last name) uses code essentially identical.<BR><BR>That&#039s the bad news.<BR><BR>The good news is you&#039ve solved a problem yourself and can pat yourself on the back. Congratulations.<BR><BR>Bill Wilkinson

  5. #5
    Peter S. Guest

    Default RE: Dynamic Includes - Possible workaround? Critiq

    I&#039m not sure what you mean by not being able to parse it futhur and it may be that you mean what I am about to ask...<BR><BR>Anyway, the problem with your suggestion is that further ASP code will cannot be processed within the file you are including. It will treat the asp code as html, static. Therefore unless the pages you are including are for only static and client-side vb/java scripts, then your solution works, otherwise it still does not solve the problems of using this method versus SSI.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts