Creazione array per passaggio parametri a Flash
TheNoob non è online. Ultima attività: 18/08/2008 14.51.54TheNoob
Inserito il: 21 luglio 2008 11.32
9 messaggi dal 15 lug 2008 Istalla Microsoft Silverlight!
Come da titolo (e tenete presente che sono poco più di un neofita  ):
ho uno script ASP che permette di visualizzare tutte le directory, subdirectory e file partendo da una cartella a piacere. Lo script in questione visualizza i risultati di questa esplorazione sotto forma di una tabella generata dinamicamente in cui ogni casella rappresenta un link ad un oggetto.
Mi trovo nella necessità di trasformare l'output di questo script in una serie di variabili da passare ad un'applicazione flash che provvederà a generare dinamicamente una serie di pulsanti di navigazione (uno per ogni cartella NON VUOTA e uno per ogni file), conservando la struttura in cartelle e sottocartelle originaria.
Il codice ASP è questo:

<%
Const strRootPath = "ROOT"

Dim strThisPage ' This page's relative URL
Dim strPath ' Path of directory to show
Dim strFullPath ' strRootPath & strPath
Dim objFSO ' FileSystemObject
Dim objFolder ' Folder
Dim objItem ' Looping variable

' Set the URL of this script to a variable so we don't
' have to keep looking it up.
strThisPage = Request.ServerVariables("URL")

' Read the subfolder to show from the querystring.
strPath = Request.QueryString("path")

' Check to make sure no one is trying to escape our root path.
If InStr(1, strPath, ".", 1) <> 0 Then strPath = ""
If InStr(1, strPath, Server.URLEncode("."), 1) <> 0 Then strPath = ""

strFullPath = strRootPath & strPath

' Create our FSO and get a handle on our folder
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(Server.MapPath(strFullPath))

' Show a description line and the title row of our table
%>

<table border="1" cellspacing="0" cellpadding="2">

<%

' First deal with any subdirectories. This is where the recursive
' script varies from the normal one. Take a look at how we build
' the link URLs.

' Show a link to the parent folder is applicable.
If strFullPath <> strRootPath Then
%>
<tr>
<td><a href="<%= strThisPage & "?path=" & Left(strPath, InStrRev(strPath, "/") - 1) %>">..</a></td>

</tr>
<%
End If

' Show a link for each folder. The link calls this script again
' and passes it the path to the folder clicked upon.
For Each objItem In objFolder.SubFolders
' Deal with the stupid VTI's that keep giving our visitors 404's
If InStr(1, objItem, "_vti", 1) = 0 Then
%>
<tr>
<td><a href="<%= strThisPage & "?path=" & strPath & "/" & objItem.Name %>"><%= objItem.Name %></a></td>

</tr>
<%
End If
Next 'objItem

' Now that I've done the SubFolders, do the files!
For Each objItem In objFolder.Files
%>
<tr>
<td><a href="<%= strFullPath & "/" & objItem.Name %>"><%= objItem.Name %></a></td>

</TR>
<%
Next 'objItem

' All done! Kill off our object variables.
Set objItem = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
%>
</table>

Come fare?
Grazie fin da ora per l'attenzione.
RE: Creazione array per passaggio parametri a Flash
TheNoob non è online. Ultima attività: 18/08/2008 14.51.54TheNoob
Inserito il: 21 luglio 2008 14.02
9 messaggi dal 15 lug 2008 Istalla Microsoft Silverlight!
Ehmmmmmm....... C'è nessuno? Ho spopolato il forum con una domanda  ?
Re: Creazione array per passaggio parametri a Flash
novecento non è online. Ultima attività: 27/08/2008 20.09.27novecento
Inserito il: 21 luglio 2008 21.52
contributi / Community manager / www.soluzioni4d.it / Blog / 739 messaggi dal 04 mar 2004 Istalla Microsoft Silverlight!
Ciao,
vista la natura dei dati che vuoi rappresentare ti consiglio di creare delle pagine asp che restituiscano la struttura del file system sotto forma di XML, tra l'altro questo tipo di dati puoi manipolarli in Flash in modo molto facile.

Creare delle pagine asp che restituiscano questo tipo di dati significa fare quello che stai facendo ma invece che costruire una tabella html devi creare una struttura xml con nodi e attributi in modo che richiamandola da un browser ti renderizzi a video i valori, successivamente da Flash potrai richiamare questa pagina, effettuare il parsing e ricreare una struttura "ad array" in modo da poterci accedere con indicizzatori in modo facile e veloce, a quel punto puoi dargli qualunque interfaccia più ti piaccia.
Se ti sembra che l'idea non abbia controindicazioni per il tuo progetto possiamo approfondire come si può mettere in pratica, cmq ti suggerisco questo perchè in passato ho fatto una cosa simile ed è stato molto divertente realizzarlo.

Alessio Leoncini
SilverlightItalia.com
Re: Creazione array per passaggio parametri a Flash
TheNoob non è online. Ultima attività: 18/08/2008 14.51.54TheNoob
Inserito il: 22 luglio 2008 08.39
9 messaggi dal 15 lug 2008 Istalla Microsoft Silverlight!
Molte grazie per la risposta.
Sì, una struttura XML non mi dispiacerebbe, anzi sarebbe preferibile sotto certi punti di vista. Sono però totalmente digiuno di XML, avrei bisogno di un notevole aiuto esterno in questo caso, e mi servirebbe una risposta entro giovedì mattina (so di chiedere molto, ma sono subentrati altri problemi  ).

Grazie fin da ora per ogni aiuto.
Re: Creazione array per passaggio parametri a Flash
makbox non è online. Ultima attività: 26/08/2008 14.26.48makbox
Inserito il: 23 luglio 2008 14.43
20 messaggi dal 24 mag 2002 Istalla Microsoft Silverlight!
Creare una struttura XML non è molto diversa da crearne una HTML, sempre di tag si tratta. La differenza rispetto al codice che hai già postato è quella di "inventarsi" dei nodi che rappresentano quello che ti serve. ad esempio

<folder name="">
<files>
<file name="" />
<file name="" />
<file name="" />
.....
</files>
<folders>
<folder name="">
....
</folder>
</folders>
</folder>

etc, etc..

Ricordati comunque di aggiungere la prima riga
<?xml version="1.0" encoding="ISO-8859-1"?>
aggiungere un documentelement generale (ad es. <elementlist>)
e di impostare il contenttype della pagina ASP
response.ContentType = "text/xml"

Marco.

Re: Creazione array per passaggio parametri a Flash
TheNoob non è online. Ultima attività: 18/08/2008 14.51.54TheNoob
Inserito il: 23 luglio 2008 15.16
9 messaggi dal 15 lug 2008 Istalla Microsoft Silverlight!
Const strRootPath = "ROOT"

Dim strThisPage ' This page's relative URL
Dim strPath ' Path of directory to show
Dim strFullPath ' strRootPath & strPath
Dim objFSO ' FileSystemObject
Dim objFolder ' Folder
Dim objItem ' Looping variable
Dim testo ' variabile contenente il testo del singolo pulsante di cartella

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

function iterate_folder (strFullPath)
Set objFolder = objFSO.GetFolder(Server.MapPath(strFullPath))
For Each objItem In objFolder.SubFolders
%><folder name= '<%=objItem.Name %>'>
<%
testo = strFullPath & "/" & objItem.Name
lung1 = len (testo)
pos1 = instr (testo, "_")
contr1 = lung1 - pos1
stringa1 = right (testo, contr1)
iterate_folder (testo)
Next
for each fileItem in objFolder.files
nomeFile = fileItem.Name
lung2 = len (nomeFile)
pos2 = instr (nomeFile, ".")
contr2 = lung2 - pos2
stringa2 = right (nomeFile, contr2)
%><file name= '<%=stringa2 %>'>
<%
next
%>
</folder>
<%
end function

' Set the URL of this script to a variable so we don't
' have to keep looking it up.
strThisPage = Request.ServerVariables("URL")
cont = 0

' Read the subfolder to show from the querystring.
strPath = Request.QueryString("path")

' Check to make sure no one is trying to escape our root path.
If InStr(1, strPath, ".", 1) <> 0 Then strPath = ""
If InStr(1, strPath, Server.URLEncode("."), 1) <> 0 Then strPath = ""

' Simply to save typing and computation later.
%>
fullXmlText=<root>
<%
strFullPath = strRootPath & strPath
iterate_folder (strFullPath)


'set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")
'xmlDoc.async="false"
'xmlDoc.loadXML(fullXmlText)
'xmlDoc.Save("index.xml")




'End If


%>
</root>
<%
' All done! Kill off our object variables.
Set objItem = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
%>

Questo è il codice rimaneggiato che sono riuscito a scrivere.
Precisamente, la riga
<?xml version="1.0" encoding="ISO-8859-1"?>
e il response.ContentType = "text/xml" dove vanno inseriti?

(Rinnovo i ringraziamenti per l'aiuto)
Re: Creazione array per passaggio parametri a Flash
makbox non è online. Ultima attività: 26/08/2008 14.26.48makbox
Inserito il: 23 luglio 2008 16.49
20 messaggi dal 24 mag 2002 Istalla Microsoft Silverlight!
<?xml version="1.0" encoding="ISO-8859-1"?> deve essere la prima riga del codice xml generato, in pratica fai girare la pagina visualizza il codice generato, la prima riga deve essere questa.

response.ContentType = "text/xml" aggiungilo all'inizio come prima riga dello script ASP.

Marco.

Re: Creazione array per passaggio parametri a Flash
TheNoob non è online. Ultima attività: 18/08/2008 14.51.54TheNoob
Inserito il: 24 luglio 2008 09.23
9 messaggi dal 15 lug 2008 Istalla Microsoft Silverlight!
Perdonate l'insistenza ma non riesco a venirne a capo (e il tempo stringe  )
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% Response.ContentType="text/xml" %>
<?xml version="1.0" encoding="iso-8859-1"?>

<%

Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 10
Repeat1__index = 0
rstFiles_numRows = rstFiles_numRows + Repeat1__numRows

Const strRootPath = "ROOT"

Dim strThisPage ' This page's relative URL
Dim strPath ' Path of directory to show
Dim strFullPath ' strRootPath & strPath
Dim objFSO ' FileSystemObject
Dim objFolder ' Folder
Dim objItem ' Looping variable
Dim testo ' variabile contenente il testo del singolo pulsante di cartella

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

function iterate_folder (strFullPath)
Set objFolder = objFSO.GetFolder(Server.MapPath(strFullPath))
For Each objItem In objFolder.SubFolders
%>
<%
testo = strFullPath & "/" & objItem.Name
lung1 = len (testo)
pos1 = instr (testo, "_")
contr1 = lung1 - pos1
stringa1 = right (testo, contr1)
'response.write(testo)
'response.write(stringa1)
iterate_folder (testo)
Next
for each fileItem in objFolder.files
nomeFile = fileItem.Name
lung2 = len (nomeFile)
pos2 = instr (nomeFile, ".")
contr2 = lung2 - pos2
stringa2 = right (nomeFile, contr2)
'response.write(nomeFile)
'response.write(stringa2)
%>
<%
next
%>

<%
end function

' Set the URL of this script to a variable so we don't
' have to keep looking it up.
strThisPage = Request.ServerVariables("URL")

' Read the subfolder to show from the querystring.
strPath = Request.QueryString("path")

' Check to make sure no one is trying to escape our root path.
If InStr(1, strPath, ".", 1) <> 0 Then strPath = ""
If InStr(1, strPath, Server.URLEncode("."), 1) <> 0 Then strPath = ""

%>


<%
strFullPath = strRootPath & strPath
iterate_folder (strFullPath)

%>

<%
' All done! Kill off our object variables.

Set objItem = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
%>

Ultima versione del codice. Ovviamente non funziona come dovrebbe  e produce questo bel messaggio di errore:
XML document must have a top level element. Error processing resource 'http://localhost/prova/indexml2.asp'.

Dove sbaglio?

Modificato da TheNoob il 24 luglio 2008 08.29 -


Pagine: [1] 2 Avanti >>
Vai a:
Torna al forum |   Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.


fabrica - 1622 pt
vladimiro - 1550 pt
PeppeDotNet - 700 pt

Ultimi vincitori: PeppeDotNet, fabrica, vladimiro

Iscriviti anche tu e raccogli punti. Questo mese in palio VS 2008 + Windows Server 2008, ReShaper e 1 ebook!



COMMUNITY
ULTIMI MESSAGGI


IN EVIDENZA
MISC
Powered by .db Forums