|
-
Nov 15th, 2001, 11:46 AM
#1
Thread Starter
Member
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
-
Nov 15th, 2001, 11:58 AM
#2
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
-
Nov 15th, 2001, 12:08 PM
#3
Thread Starter
Member
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
-
Nov 15th, 2001, 12:30 PM
#4
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
-
Nov 15th, 2001, 02:16 PM
#5
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|