...

View Full Version : going to the next line in text file



spetsnaz
07-12-2004, 12:14 PM
<%
''''''''''''''''''''''''''''''''''''''''''''''''''declare crap
dim fs
dim f
dim lines
dim x
'''''''''''''''''''''''''''''''''''''''''''''''''' set up all variables
input = request.QueryString("textfield")
set fs = Server.CreateObject("Scripting.FileSystemObject")
set f = fs.OpenTextFile(Server.MapPath("text.txt"),1,true,-2)


'''''''''''''''''''''''''''''''''''''''''''''''''' count the number of files
lines = 0
do while f.AtEndOfStream = false
lines = lines + 1
loop
'''''''''''''''''''''''''''''''''''''''''''''''''' check for username
for x=1 to lines
if input = f.ReadLine then
a = true
exit for
else
a = false
end if
next

'''''''''''''''''''''''''''''''''''''''''''''''''' infor user of his/her registration statues
if a = true then
Response.Write("you are registered")
else
Response.Write("you are not registered")
end if

'''''''''''''''''''''''''''''''''''''''''''''''''' prevent memory leaks
f.close
set f = nothing
set fs = nothing
%>

in the section "check for username" am i going to the next line after reading the current line? coz at the min iam just getting an infinite loop as for some reason the script never exists that for loop. if it doesnt goto the next line how does make i go to thenext line? also is it legal to use exit for like i have in the "check for username".

Roy Sinclair
07-12-2004, 10:24 PM
Your inifinite loop is in the "count the number of files" part of the code which is just before the section of code you thought the loop was in.

You're not reading lines in that bit of code so you never reach a f.AtEndOfStream condition.

spetsnaz
07-12-2004, 10:32 PM
yer.


<%
'''''''''''''''''''''''''''''''''''''''''''''''''' declare crap
dim fs
dim f
dim lines
dim x
'''''''''''''''''''''''''''''''''''''''''''''''''' set up all variables
input = request.QueryString("textfield")
set fs = Server.CreateObject("Scripting.FileSystemObject")
set f = fs.OpenTextFile(Server.MapPath("text.txt"),1,true,-2)


'''''''''''''''''''''''''''''''''''''''''''''''''' count the number of files
lines = 0
do while f.AtEndOfStream = false
f.readline
lines = lines + 1
loop
'''''''''''''''''''''''''''''''''''''''''''''''''' return to line 1
f.close
set f = fs.OpenTextFile(Server.MapPath("text.txt"),1,true,-2)

'''''''''''''''''''''''''''''''''''''''''''''''''' check for username
for x=1 to lines
if input = f.ReadLine then
a = true
exit for
else
a = false
end if
next

'''''''''''''''''''''''''''''''''''''''''''''''''' infor user of his/her registration statues
if a = true then
Response.Write("you are registered")
else
Response.Write("you are not registered")
end if

'''''''''''''''''''''''''''''''''''''''''''''''''' prevent memory leaks
f.close
set f = nothing
set fs = nothing
%>


i modified the code to make it work. thanx for the quick reply. it works now. many thanx



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum