Read Asc File


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Read Asc File

  1. #1
    Join Date
    Mar 2005
    Posts
    96

    Read Asc File

    For the love of God i cannot figure out what i am doing wrong. I have an Input file that i am using to feed into my program and it is supposed to read lines till it hits a line with **** on it. Then it is supposed to do a bunch of things on the lines it read and then it is supposed start of from where it left it. I have the first part down but when it is supposed to start reading lines back up it skips 2 lines. I cannot figure out why. PLEASE HELP!

    This is what i have:

    Do
    i = 0
    Line Input #s1, testtype
    testtype = Trim(Right$(testtype, Len(testtype) - InStr(testtype, ":")))
    Line Input #s1, datadir
    datadir = Trim(Right$(datadir, Len(datadir) - InStr(datadir, ":")))
    Do
    i = i + 1
    Input #s1, chnname(i), chncomment(i), dummyser(i), speed(i)
    Loop Until InStr(chnname(i), "*******") > 0
    linesread = i - 1
    .
    .
    .
    .
    .
    Loop Until linesread >= totallines

    where totallines = 111 (number of lines in my input file).

    I am attaching my input file to this. Thanks.
    Attached Files Attached Files

  2. #2
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    you are reading two lines in the outer loop without increasing i (by 2), I think because in the inner loop i must be 1, but then linesread (i-1) is not the total number of lines
    Marco
    PS please leave deity, divinity, or gods out of here, there always the risk to offend someone
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  3. #3
    Join Date
    Mar 2005
    Posts
    96
    2 things:
    1. I did not mean to offend anyone with my comment. If i did, i apologize. It was completely unintentional.
    2. mstraf - i still have no idea how to fix the problem at hand!

    Thanks ~svn

  4. #4
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    change

    linesread = i - 1

    with

    linesread = linesread + (i + 2)

    or forget the linesread count, and check for EOF (it is much safer and will save headache later), as the first line in the first loop (this is my strong suggestion):

    Do
    if EOF(s1) then exit do

    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  5. #5
    Join Date
    Mar 2005
    Posts
    96
    Thanks but i figured it out. I made it write a file with what it was reading and i saw that when it was reading the line with ***** it was also reading the next 3 values separated by commas due to the line:
    Input #s1, chnname(i), chncomment(i), dummyser(i), speed(i)

    but i changed that in my input file and it now reads **** for the 3 variables that follow.

    In any case, thanks for all the help mstraf.

Similar Threads

  1. Replies: 1
    Last Post: 04-02-2002, 11:45 PM
  2. Read a file on the client
    By Andrea in forum ASP.NET
    Replies: 1
    Last Post: 09-28-2001, 06:25 PM
  3. How to use Java to lock a file
    By Cynthia Leslie in forum Java
    Replies: 3
    Last Post: 06-09-2001, 07:43 PM
  4. Replies: 12
    Last Post: 05-18-2001, 05:05 AM
  5. how to read text file using JAVA...??
    By Billy in forum Java
    Replies: 3
    Last Post: 02-02-2001, 09:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center