Visualizzazione dei risultati da 1 a 3 su 3

Discussione: impaginare fso

  1. #1
    Utente di HTML.it L'avatar di jet
    Registrato dal
    Dec 2002
    residenza
    Chieti
    Messaggi
    866

    impaginare fso

    Salve, vorrei impaginare file recuperati con fso.

  2. #2

  3. #3
    un po' di tempo fa avevo creato questo script per impaginare dei record lunghi prelevati da database. ti basta sostituire la parte database con quella fso e tutto dovrebbe andare senza problemi

    codice:
    <%
    '########################################################################'
    '##################### IMPAGINARE RECORDS LUNGHI ########################'
    '########################################################################'
    
    Function impagina(testo,page) '### Funzione per impaginare i records lunghi
          testo=TRIM(testo)
          
          m_len=3000    '# Lunghezza oltre la quale spezzare il testo
          t_lim=25      '# Limite di tolleranza (se lt<m_len+t_lim allora non serve spezzare)
          b_lim=150     '# Limite inferiore (quando il testo visualizzato è più corto di m_lim e lt>m_lim... questione estetica)
          lt=len(testo) '# Lunghezza complessiva del testo
          
          testo = replace(testo,chr(13),"
    ")
          
          ReDim arr_testo(0)
          
          if not lt>(m_len+t_lim) then
             arr_testo(0)=testo
           else
             
             s=0
             break_in=1
             tmp_lt=lt
             do until tmp_lt<m_len'<m_len ' # ciclo finchè è più lungo della lung max
                leave_from=break_in+m_len
                lb = inStrRev(testo,"
    ",leave_from)
                rb = inStr(leave_from,testo,"
    ")
             
                If rb<>0 then
                   If lb<>0 then
                      If ((m_len-lb)<(rb-m_len)) and ((m_len-lb)<b_lim) then
                         break_in=lb
                       else
                         break_in=rb
                         if (rb+t_lim)>lt then break_in=lt
                      End if
                    else
                      break_in=rb
                      if (rb+t_lim)>lt then break_in=lt
                   End if
                 else
                   break_in=lt
                End if
             
                tmp_txt = mid(testo,(lt-tmp_lt+1),(tmp_lt-(lt-break_in)-1))
                If s=0 then 
                   arr_testo(0)=tmp_txt
                elseif s>0 then
                   tmp_txt = TRIM(right(tmp_txt,(len(tmp_txt)-3)))
                   'If lcase(left(tmp_txt,4))="
    " then Response.Write "prova"
                   ReDim preserve arr_testo(s)
                     arr_testo(s)=tmp_txt
                End if
                
                tmp_lt=lt-break_in
                s=s+1
             loop
          End if
          
          If tmp_lt>0 then
             ReDim preserve arr_testo(s)
                arr_testo(s)=TRIM(mid(testo,break_in))
          End if
          
          txt=arr_testo(page-1)
          'Levo eventuali "accapo" in testa e in fondo
          do
            If lcase(left(TRIM(txt),4))="
    " then 
               txt=TRIM(Right(TRIM(txt),len(txt)-4))
             else
               exit do
            End if
          loop
          
          do
            If lcase(Right(TRIM(txt),4))="
    " then 
               txt=TRIM(Left(TRIM(txt),len(txt)-4))
             else
               exit do
            End if
          loop
          
          Response.Write txt
          
          If UBound(arr_testo)>0 then   ' # Visualizzo il link alle pagine
             Response.Write "
    
    <div align='center'>Pagina: "
             For a=0 to UBound(arr_testo)
                 p=a+1
                 If (p)=cint(page) then
                    Response.Write "" & p & ""
                  else
                    Response.Write "" & p & ""
                 End if
                 
                 If a<UBound(arr_testo) then Response.Write " - "
             Next
             Response.Write "</div>"
          End if
    
    End function
    
    
    '### Connessione e apertura recordset
    dim conn
    
    set rs=server.CreateObject("ADODB.Recordset")
    Set conn = Server.CreateObject("ADODB.Connection")
    
    ConnString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("../mdb-database/forum_db.mdb") & "; Persist Security Info=False"
    conn.Open ConnString
    
    sql="SELECT T_Subject, T_Message FROM Topics WHERE Topic_ID = 85"
    rs.Open sql,conn,1,3
    %>
    
    <html>
    <body>
    
    <TABLE bgcolor="gray" border="1" bordercolor="black" align="center" valign="top" width="400" height="auto">
     <tr>
        <td align="left"><%If not rs.EOF then Response.Write rs("T_Subject")%></td>
     </tr>
     <tr valign="top">
        <td align="justify">
        
        
        <%
        If (Request.QueryString("page")="") or (isNumeric(Request.QueryString("page"))=false) then 
           page=1
         else
           page=Request.QueryString("page")
        End if
        
        If not rs.EOF then
           impagina rs("T_Message"),page
        End if
        %>
        
        
        </td>
     </tr>
    </table>
    
    </body>
    </html>
    
    <%
    rs.Close
    set rs=nothing
    
    conn.Close 
    set conn=nothing
    %>
    xxx

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.