Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    going to the next line in text file

    Code:
    <%
    ''''''''''''''''''''''''''''''''''''''''''''''''''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".

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yer.
    Code:
    <%
    ''''''''''''''''''''''''''''''''''''''''''''''''''  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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •