Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts

    include file question

    I have the following code in place
    Code:
    <%
    If CDate(FormatDateTime(DateTimeViewed,2)) > CDate("11/21/2011") AND CDate(FormatDateTime(DateTimeViewed,2)) < CDate("7/22/2012") Then 
    %>
    <!-- #include FILE="../Includes/assessmentfunctions.asp" -->
    <%
    ElseIf CDate(FormatDateTime(DateTimeViewed,2)) < CDate("11/21/2011")  Then 
    %>
    <!-- #include FILE="../Includes/oldassessmentfunctions.asp" -->
    <%
    Else
    %>
    <!-- #include FILE="../Includes/RevisedAssessmentFunctions.asp" -->
    <%	
    End If
    %>
    The DateTimeViewed is a variable that is pulled from a database.

    There are some functions that have been slightly altered in the different versions of the include file

    In each of the include files on the first line I write a comment out that says which file is loaded. That way I can view the source and supposedly see
    Which version is being used

    OK now here is the problem. I noticed that even if it writes out that it loaded AssessmentFunctions.asp, the changed function that it is using are coming from RevisedAssessmentFuntions.asp

    So this leads me to believe that all of the include files are loading regardless of any if statements. Is this correct?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,198
    Thanks
    80
    Thanked 4,453 Times in 4,418 Posts
    So this leads me to believe that all of the include files are loading regardless of any if statements. Is this correct?
    Yes.

    http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=55

    One of the first FAQs I ever wrote. And even back then I wrote it because I think we answered this same question about once every three days in those forums.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    miranda (07-19-2012)

  • #3
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Thanks Bill. I knew you would know and could confirm. I had a feeling that is what happens. Unfortunately I put the code in production environment and got major egg on my face this morning from it.

    Oh well goes to show I am human.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,198
    Thanks
    80
    Thanked 4,453 Times in 4,418 Posts
    Ouch. Well, I followed advice of IT guys yesterday and caused automatic emails to stop being sent, so I know whereof you speak. I should have tested it before believing them.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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