Results 1 to 5 of 5

Thread: parse text file with loop inside

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2001
    Posts
    55

    parse text file with loop inside

    i'm trying to parse a text file, the problem is that at certain points of the file, i need to loop through certain parts of the file. For example:

    **tag1 : some info here
    **tag2 : more info
    **tag3 : info
    **this is where i need to loop thru
    **info, if there is no colons on the line.
    **and i need to concatenate it

    if the line contains a ":", there's no problem, but the minute i need to loop thru a part, i'm not sure how to handle it.

    do until eof(1)
    line input #1, s
    if instr(s, ":") > 0 then
    'grabs necessary info
    else
    'need to loop and get info, having problems here
    endif

  2. #2
    vbGrandpa
    Guest
    Try this.

    dim colon as boolean

    colon=false
    do until eof(1)
    line input #1, s
    if instr(s, ":") then
    colon=True
    else
    colon=False
    endif

    if colon=true
    process one way
    endif

    if colon=false
    process other way
    endif

    loop

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2001
    Posts
    55
    sorry if i didn't explain clearly vbGrandpa, the problem is the way to handle the looping of specific areas of the file and to concatenate the text until the end of the loop. Once inside the loop, how do i grab each line of text and concatenate until the next time it hits a line containing a colon? Thanks

  4. #4
    vbGrandpa
    Guest
    dim colon as boolean
    dim concatstring as string

    colon=false
    concatstring=""
    do until eof(1)
    line input #1, s
    if instr(s, ":") then
    colon=True
    else
    colon=False
    endif

    if colon=true then
    process one way
    endif

    if colon=false then
    concatstring=concatstring & s
    endif

    loop

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2001
    Posts
    55
    thanks vbGrandpa, works great now

Posting Permissions

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



Click Here to Expand Forum to Full Width