<%
filePath = Server.Mappath(“file_testo.txt”)
Set objFileSystem = Server.CreateObject(“Scripting.FileSystemObject”)
if objFileSystem.FileExists(filePath ) then
‘apro file in lettura
Set objFile = objFileSystem.OpenTextFile(filePath, 1)
‘scrivo a video contenuto file
Response.Write objFile.ReadAll
‘oppure lo inserisco in una variabile contenuto_testo=objFile.ReadAll
objFile.Close
Set objFile=Nothing
end if
Set objFileSystem=Nothing
%>
Con questo script leggiamo il file riga per riga:
<%
filePath = Server.Mappath(“file_testo.txt”)
Set objFileSystem = Server.CreateObject(“Scripting.FileSystemObject”)
if objFileSystem.FileExists(filePath ) then
Set objFile = objFileSystem.OpenTextFile(filePath, 1)
‘leggo file riga per riga fino alla fine del file
Do While Not objFile.AtEndofStream
Response.Write objFile.ReadLine & “<br>”
Loop
objFile.Close
Set objFile=Nothing
end if
Set objFileSystem=Nothing
%>
Scrivo il testo nel file (controllare la cartella abbia i permessi di scrittura) e se il file non esiste lo creo:
<%
filePath = Server.Mappath(“file_testo.txt”)
Set objFileSystem = Server.CreateObject(“Scripting.FileSystemObject”)
if not objFileSystem.FileExists(filePath) then
‘se non esiste lo creo
objFileSystem.CreateTextFile(filePath)
end if
Set objFile = objFileSystem.OpenTextFile(filePath, 2)
‘scrivo una riga sul file
‘ objFileSystem.OpenTextFile(filePath, 2) -> sovrascrivo file
‘ objFileSystem.OpenTextFile(filePath, 8) -> aggiungo il testo al fondo del file
objFile.WriteLine(“nuovo testo file”)
objFile.Close
Set objFile=Nothing
Set objFileSystem=Nothing
%>
Cercare parola in un array: Dim stringa, arr stringa = "Luca andiamo avanti per la strada" arr = Split(stringa, " ") For x = 0 To Ubound(arr) if arr(x) = "avanti" then response.write "Parola esiste SI!" trovata = 1 end if next if trovata = 0 then response.write "Parola esiste NO!" end if
for j = 1 to 99 response.write "if Instr(riga, ""a"&j&""") then xa"&j&"=riga" next
for j = 11 to 99 response.write "**********************************************" response.write "ra"&j&" = Replace(xa"&j&",""a"&j&" = "","""")" response.write "ra"&j&" = Replace(ra"&j&", """""""", """", 1, -1, 1)" response.write "********************************************** " response.write "*** Guida completa asp ****
" next -------- stampa a video contratta ------------ With Response .Write "Data e ora attuali: " .Write Now() End With ------------- fine stampa contratta --------- ---------------- lampeggio -------------------- questa frase lampeggia ----------- fine lempeggio -------------- ----- conteggio alla rovescia ------------- For x = 100 To 1 step -1 response.write x & next ---------- fine conteggio alla rovescia -----------
if zeo = Year(Now) then
response.write "puoi vedere la pagina"
end if