Results 1 to 2 of 2

Thread: #include file using a variable for the filename

  1. #1

    Thread Starter
    Lively Member Dr_Evil's Avatar
    Join Date
    Mar 2000
    Location
    Columbus, OH
    Posts
    105
    I would like to know if it is possible to include a file by passing a variable. I am pulling the location of the files from a SQL Server DB. Everything works except for the #include.

    Ex.
    Code:
    <%
    Private Function CreateTable(Col1Width, Col2Width, Col3Width, Height)
    	Dim objRS
    	Dim objStatus  
    	Dim objDescriptionLocation
    
    	Set objRS = GetPresidentsPickByDate (1, 2001)
    
    For i = 1 to 4
    	If objRS.Fields(11).Value = 0 Then 
    		objStatus = "Backorder" 
    	Else
    		objStatus = "In Stock"
    	End If
    
    	objDescriptionLocation = objRS("Descriptionlocation")
     
        Response.Write "<tr>" & vbCRLF
        Response.Write "<td width='" & Col1Width & "' height='" & Height & "'><img border='0' src= " & objRS("GIFLocation") & " width='188' height='166'></td>" & vbCRLF
    	Response.Write "<td width='" & Col2Width & "' height='" & Height & "'><!-- #include file='" &  objDescriptionLocation & "' -->"  & vbCRLF 
    	Response.Write "<td width='" & Col3Width & "' height='" & Height & "'><p align='center'><b>'" & objStatus & "'</b></p>" & vbCRLF
    	Response.Write "</td>" & vbCRLF
    	Response.Write "</tr>" & vbCRLF
    
    	objRS.MoveNext
    Next 
    End Function
    %>
    Dr_Evil
    Senior Programmer
    VS6 EE
    VS.NET EA

  2. #2
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    give this a shot
    Code:
    <%
      dim var
      var = "myfile.txt"
    %>
    <!--#include file="<%=var%>"-->

Posting Permissions

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



Click Here to Expand Forum to Full Width