-> Given a plain text file containing:
-> xxx
-> xxx
-> yyy
-> zzz
-> How do I achive this:
-> xxxxxx
-> yyy
-> zzz
-> In other words... so long as the next line, matches the previous line.
-> join the duplicates, else wise. I'm not wanting to globally
-> join similar lines, but only so long as the line above matches.
-> Hope that makes sense.
Sense, yes, but I don't think it's a complete description. What happens
if there are three or more identical consecutive lines? Should they all
be concatenated together, or should they just be put in pairs?
Okay... Untested (and so far unwritten) code:
open "something" for input as #1
line input #1, last$
current$ = last$
do
line input #1, new$
if new$ = last$ then
current$ = current$ + new$
else
print current$
current$ = new$
last$ = new$
end if
loop until eof(1)
print current$
close 1
end
I've just used "print" as the output. Of course, you could have another
file and output to that instead.
I think that would work, concatenating two, three, or more identical
strings if they appear consecutively in the input file. If you want
them to be in pairs, you'll have to do some fiddling.
dow


|