webForumDet fria alternativet

FSO: Loopa ut alla rader!

ASP

3 svar · 309 visningar · startad av oskars

Medlem sedan nov. 20051 317 inlägg
Frågan#1

Hej,

jag har denna koden:

<div style="font-size:12px;">
<%
	set fs = Server.Createobject("scripting.FileSystemObject")
	set rfile = fs.OpenTextFile(server.mappath("testfilen.txt"))
	
	filecontent = Replace(rfile.ReadAll," ","_")
	
		'Efternamn
		col1 = Right(filecontent,211)
		col1 = Left(col1,36)
		'Namn
		col1 = Replace(col1,",","#")
		
		'Adress
		col2 = Right(filecontent,175)
		col2 = Left(col2,36)
		
		'Postnummer
		col3 = Right(filecontent,139)
		col3 = Left(col3,6)
		
		'Ort
		col4 = Right(filecontent,133)
		col4 = Left(col4,38)
		
		'Fordon
		col5 = Right(filecontent,84)
		col5 = Left(col5,24)
		
		'Årsmodell
		col6 = Right(filecontent,60)
		col6 = Left(col6,2)
		
		'Datum1
		col7 = Right(filecontent,36)
		col7 = Left(col7,6)
		
		'Datum2
		col8 = Right(filecontent,30)
		col8 = Left(col8,6)
		
		Line = col1 & "#" & col2 & "#" & col3 & "#" & col4 & "#" & col5 & "#" & col6 & "#" & col7 & "#" & col8 & "#"
		
		Response.Write Line & "<br />"
	
	rfile.close
	set rfile = nothing
	set fs = nothing
%>
</div>

Hur bygger jag om den så den går igenom varje rad och loopar ut dom på sidan?

Tacksam för hjälp!

Mvh
Oskar

Medlem sedan juni 200032 967 inlägg
#2

typ:

while not rfile.atendofstream
    foo = rfile.readline
    ' gör saker och ting med [i]foo[/i]
wend
Medlem sedan feb. 20011 198 inlägg
#3

Bifoga exempel på textfilen.

Medlem sedan nov. 20051 317 inlägg
#4

@nders skrev:

typ:

while not rfile.atendofstream
    foo = rfile.readline
    ' gör saker och ting med [i]foo[/i]
wend

Grymt! Tack!! :)

254 ms totalt · 4 externa anrop · v20260731065814-full.e96017d9
119 ms — deklarationer (db)
0 ms — hämta statistik (cache)
132 ms — hämta tråd, inlägg och bilagor (db)
118 ms — ändringar (db)