SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2004
    Location
    Milan, Italy
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    :( no error but doesn't work

    Here is my code. It doesn't give me a error and also it doesn't give me the resutl i want.

    Code:
    <%@ LANGUAGE = VBScript %>
    <% Response.Expires = 0 %>
    <!--#include file="../Area_Riservata/Sicurezza.asp"-->
    <!--#INCLUDE FILE = "IFormC.asp" -->
    <!--#INCLUDE FILE = "IForm06b.asp" -->
    <%
    Dim risposta
    Dim risposta1
    Dim ViewPath
    
    'Declare our FileSystemObject variable 
    Dim objFSO 
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    
    'Declare our folder variable 
    Dim objFolder 
     
    'web's root folder? 
    Dim strRootFolder 
    strRootFolder = "F:/Inetpub/wwwroot/intraform/Form/SpoolPDF/out/" 
    
    
    'Set web path to view the PDF from the browser
    ViewPath = "/formpdf/"
    
    'set our folder object to the web root folder 
    Set objFolder = objFSO.GetFolder(strRootFolder)
    
    'Declare a file object 
    Dim objFile 
    
    '**
    dim fNames()
    dim fDates()
    redim fNames(fileCount) 
    redim fDates(fileCount)
    Dim sExt
    Dim fileCount
    
    sExt = ".PDF"
    filecount = 0
    
    For each objFile in objFolder.files
    	if instr(objFile.Name,sExt) > 0 then
    		fileCount = filecount + 1
    		If LCase(Left(objFile.Name, 3)) = "03_" then
    			'cFcount = cFcount + 1 
            	fDates(cFcount) = objFile.DateLastModified
    			fNames(cFcount) = lcase(objFile.name)
    			Response.write objFile.Name & "<br>"
    		End If
    	end if
    next
    
    for tName = 1 to cFcount 
    	for nName = (tName + 1) to filecount
    		if (fDates(tName) < fDates(nName)) then 
    			'Sort dates
    			buffer = fDates1(nName) 
    			fDates(nName) = fDates(tName)
    			fDates(tName) = buffer 
    			'Sort names
    			buffer = fNames(nName) 
                fNames(nName) = fNames(tName)
    			fNames(tName) = buffer 
    		end if 
    	next
    next
    
    set objFolder = nothing
    set objFSO = nothing
    %>
    <html>
    <head>
    <title>Intr@Form - Identificazione Sottoscritto</title>
    <link rel="stylesheet" type="text/css" href="Layout.css">
    <style type="text/css">
    <!--
    a:hover {  color: #990000}
    -->
    </style>
    </head>
    <script language="javaScript">
    function cmdBack()
    {
            window.location = '<%if s = "" then%>IForm01.asp<%else%>IForm01.asp<%end if%>';
    }
    </script>
    <body bgcolor="#FFFFFF">
    <table width="825" border="0">
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td width="186" valign="top"><table border="0" cellspacing="1" width="158">
            <tr bgcolor="#E6E6E6">
              <td width="157" height="25"><a href="javascript:cmdBack()" class="Menu1Title">&nbsp;Precedente</a></td>
            </tr>
          </table></td>
        <td width="629" valign="top"><table width="623" border="0">
            <tr>
              <td valign="top"><div align="center"><span class="TXT_3">Registro</span> <br>
                </div></td>
            </tr>
          </table>
          <table width="623" border="1">
            <tr>
              <td width="413" valign="top"><span class="TXT_5_center">Nome File PDF</span><br>
                <%	
    	for nName = 1 to cFcount 
    	Response.Write "<span class='TXT_4'><a href='" & ViewPath & fNames(i) & "' class='TXT_4'>" & fNames(i) & "</a></span><br>"
    	next
    %></td>
              <td width="194" valign="top"><span class="TXT_5_center">Data Creazione</span><br>
                <%
    for nName = 1 to cFcount 
    	Response.Write "<span class='TXT_4'>" & fDates(i) & "</span><br>"
    	next
    %></td>
            </tr>
          </table>
          <br>
          <table width="623" border="0">
            <tr>
              <td valign="top"><div align="center"><span class="TXT_3">Cartellino</span> <br>
                </div></td>
            </tr>
          </table>
          <table width="623" border="1">
            <tr>
              <td width="413" valign="top"><span class="TXT_5_center">Nome File PDF</span><br>
              </td>
              <td width="194" valign="top"><span class="TXT_5_center">Data Creazione</span><br></td>
            </tr>
          </table>
          <br>
          <table width="623" border="0">
            <tr>
              <td valign="top"><div align="center"><span class="TXT_3">Ricevuta</span> <br>
                </div></td>
            </tr>
          </table>
          <table width="623" border="1">
            <tr>
              <td width="413" valign="top"><span class="TXT_5_center">Nome File PDF</span><br></td>
              <td width="194" valign="top"><span class="TXT_5_center">Data Creazione</span><br></td>
            </tr>
          </table></td>
      </tr>
    </table>
    </body>
    </html>
    In my Response.write i get the following "03_MOD48_2007_126103327.PDF"
    Which is correct. But when i ask it to write it in the body section it doesn't do anything. I guess the For..Each i used is wrong..

    Code:
    <table width="623" border="1">
            <tr>
              <td width="413" valign="top"><span class="TXT_5_center">Nome File PDF</span><br>
                <%	
    	for nName = 1 to cFcount 
    	Response.Write "<span class='TXT_4'><a href='" & ViewPath & fNames(i) & "' class='TXT_4'>" & fNames(i) & "</a></span><br>"
    	next
    %></td>
              <td width="194" valign="top"><span class="TXT_5_center">Data Creazione</span><br>
                <%
    for nName = 1 to cFcount 
    	Response.Write "<span class='TXT_4'>" & fDates(i) & "</span><br>"
    	next
    %></td>
            </tr>
          </table>
    Anyone??

    Thank you
    dReAm

  2. #2
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    where is the "i" variable in the second example (fNames(i) & fDates(i))? i don't see where your incrementing that out anywhere. however, i do see "nName". you should be using that instead of "i", fNames(nName) & fDates(nName).

    one thing to do that helps a bit in debugging is to put "Option Explicit" at the top of the code (in your case, 2nd line after "<&#37;@ LANGUAGE = VBScript %>". this will let you know if you have undeclared variables in your script.

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2004
    Location
    Milan, Italy
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks bbolte

    Here is my new code
    Code:
    <%@ LANGUAGE = VBScript %>
    <% Response.Expires = 0 %>
    <!--#include file="../Area_Riservata/Sicurezza.asp"-->
    <!--#INCLUDE FILE = "IFormC.asp" -->
    <!--#INCLUDE FILE = "IForm06b.asp" -->
    <%
    Dim risposta
    Dim risposta1
    Dim ViewPath
    
    'Declare our FileSystemObject variable 
    Dim objFSO 
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    
    'Declare our folder variable 
    Dim objFolder 
     
    'web's root folder? 
    Dim strRootFolder 
    strRootFolder = "F:/Inetpub/wwwroot/intraform/Form/SpoolPDF/out/" 
    
    
    'Set web path to view the PDF from the browser
    ViewPath = "/formpdf/"
    
    'set our folder object to the web root folder 
    Set objFolder = objFSO.GetFolder(strRootFolder)
    
    'Declare a file object 
    Dim objFile 
    
    '**
    dim fNames()
    dim fDates()
    redim fNames(fileCount) 
    redim fDates(fileCount)
    Dim sExt
    Dim fileCount
    
    sExt = ".PDF"
    filecount = 0
    
    For each objFile in objFolder.files
    	if instr(objFile.Name,sExt) > 0 then
    		fileCount = filecount + 1
    		If Left(objFile.Name, 9) = "MOD48_03_" then
    			'cFcount = cFcount + 1 
            	fDates(cFcount) = objFile.DateLastModified
    			fNames(cFcount) = lcase(objFile.name)
    			Response.write objFile.Name & "<br>"
    		End If
    	end if
    next
    
    for tName = 1 to filecount
    Response.write "1" & "<br>"
    	for nName = (tName + 1) to filecount
    	Response.write "2" & "<br>"
    	Response.write "tName = " & tName & "<br>"
    	Response.write "nName = " & nName & "<br>"
    		if (fDates(tName) < fDates(nName)) then 
    			Response.write "3" & "<br>"
    			'Sort dates
    			buffer = fDates(nName) 
    			fDates(nName) = fDates(tName)
    			fDates(tName) = buffer 
    			'Sort names
    			buffer = fNames(nName) 
                fNames(nName) = fNames(tName)
    			fNames(tName) = buffer 
    		end if 
    	next
    next
    
    set objFolder = nothing
    set objFSO = nothing
    %>
    <html>
    <head>
    <title>Intr@Form - Identificazione Sottoscritto</title>
    <link rel="stylesheet" type="text/css" href="Layout.css">
    <style type="text/css">
    <!--
    a:hover {  color: #990000}
    -->
    </style>
    </head>
    <script language="javaScript">
    function cmdBack()
    {
            window.location = '<%if s = "" then%>IForm01.asp<%else%>IForm01.asp<%end if%>';
    }
    </script>
    <body bgcolor="#FFFFFF">
    <table width="825" border="0">
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td width="186" valign="top"><table border="0" cellspacing="1" width="158">
            <tr bgcolor="#E6E6E6">
              <td width="157" height="25"><a href="javascript:cmdBack()" class="Menu1Title">&nbsp;Precedente</a></td>
            </tr>
          </table></td>
        <td width="629" valign="top"><table width="623" border="0">
            <tr>
              <td valign="top"><div align="center"><span class="TXT_3">Registro</span> <br>
                </div></td>
            </tr>
          </table>
          <table width="623" border="1">
            <tr>
              <td width="413" valign="top"><span class="TXT_5_center">Nome File PDF</span><br>
                <%	
    	for tName = 1 to cFcount 
    	Response.Write "<span class='TXT_4'><a href='" & ViewPath & fNames(tName) & "' class='TXT_4'>" & fNames(tName) & "</a></span><br>"
    	next
    %></td>
              <td width="194" valign="top"><span class="TXT_5_center">Data Creazione</span><br>
                <%
    for tName = 1 to cFcount 
    	Response.Write "<span class='TXT_4'>" & fDates(tName) & "</span><br>"
    	next
    %></td>
            </tr>
          </table>
          <br>
          <table width="623" border="0">
            <tr>
              <td valign="top"><div align="center"><span class="TXT_3">Cartellino</span> <br>
                </div></td>
            </tr>
          </table>
          <table width="623" border="1">
            <tr>
              <td width="413" valign="top"><span class="TXT_5_center">Nome File PDF</span><br>
              </td>
              <td width="194" valign="top"><span class="TXT_5_center">Data Creazione</span><br></td>
            </tr>
          </table>
          <br>
          <table width="623" border="0">
            <tr>
              <td valign="top"><div align="center"><span class="TXT_3">Ricevuta</span> <br>
                </div></td>
            </tr>
          </table>
          <table width="623" border="1">
            <tr>
              <td width="413" valign="top"><span class="TXT_5_center">Nome File PDF</span><br></td>
              <td width="194" valign="top"><span class="TXT_5_center">Data Creazione</span><br></td>
            </tr>
          </table></td>
      </tr>
    </table>
    </body>
    </html>
    But i get an error now

    Code:
    1
    2
    tName = 1
    nName = 2
    
    Microsoft VBScript runtime error '800a0009'
    
    Subscript out of range: '1'
    
    /it/intraform.demo/visualizza_pdf.asp, line 62
    Line 62 is

    Code:
    Response.write "3" & "<br>"
    Any help?

    Thanks
    dReAm

  4. #4
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually, i'm betting the error is in this line: if (fDates(tName) < fDates(nName)) then. maybe (tName + 1) is throwing it off.

  5. #5
    SitePoint Zealot
    Join Date
    Sep 2004
    Location
    Milan, Italy
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so what could i use for it?
    dReAm

  6. #6
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    remove the +1, what happens then?

  7. #7
    SitePoint Zealot
    Join Date
    Sep 2004
    Location
    Milan, Italy
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. I changed it the way you said. BUt nothing works. It doesn't enter the

    Code:
    if (fDates(tName) < fDates(nName)) then
    dReAm

  8. #8
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    response.write out filecount and make sure it has a value, response.write ubound(fnames) and ubound(fdates) and make sure those arrays have values.

  9. #9
    SitePoint Zealot
    Join Date
    Sep 2004
    Location
    Milan, Italy
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When it gives me this message it also shows me the table where the names are suppose to be.
    Code:
    MOD48_03_2007_259344.PDF
    filecount 1
    Section 1
    tName = 1
    nName =
    fnames 0 fdates 0
    When i have this code it gives me an error on the line 65
    Code:
    if (fDates(tName) < fDates(nName)) then
    Code:
    MOD48_03_2007_259344.PDF
    MOD48_03_2007_259376.PDF
    filecount 2
    Section 1
    tName = 1
    nName =
    fnames 0 fdates 0
    Section 2
    tName = 1
    nName = 2
    
    Microsoft VBScript runtime error '800a0009'
    
    Subscript out of range: '1'
    
    /it/intraform.demo/visualizza_pdf.asp, line 65
    Whyyyyyyyyyyyyyyyyy ??
    dReAm

  10. #10
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is it because of this:
    Code:
    nName =
    fnames 0 fdates 0
    ?


Bookmarks

Posting Permissions

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