Thanks again Eric!
You actually anticipated my next step.....
Later on today I hope to send you a break-down on the 
entire project that I am attempting to do in Rebol.
It may interest you, and there's some other things
that have come up that may be of interest also.
regards
Tim
At 11:09 AM 2/10/00 +0900, you wrote:
>
>Hi Tim,
>
>I modified my last attempt to handle insertion of text as well. This
>new version assumes that there's only one stretch of the file that
>will be replaced.
>
>Ladislav already told you the important point, although he didn't explain
>it. Once you've inserted something into a series (or port), you can use
>the return value of INSERT to get the position in the series following the
>insert. This is great if you need to make several inserts.
>
>Actually since this function only makes one replacement, it would have been
>easier to remove the lines first and then make the insert, and not even
>worry about where we are in the series after that. But it's just as well
>to keep track of the position so it'll be easier to expand the code later.
>
>
>In the previous thread you asked about reusing code in REBOL. There is
>quite a lot of useful stuff on www.rebol.org, but it's all scripts that
>people have posted - nothing that's been organized into a coherent library.
>There are some folks who are working on improving rebol.org, but I don't
>know how far they have gotten. I haven't noticed any changes yet.
>
>See you,
>Eric
>
>==========
>
>replace-text: func [
>    fp [file!] "text file with lines to be updated"
>    rp [file!] "text file holding lines to be inserted"
>][
>    fp: open/lines fp
>    rp: read/lines rp
>    lines_removed:  0
>    lines_inserted: 0
>    while [ not tail? fp ] [
>        if find first fp "begin replace here" [
>            print "found"
>            fp: next fp
>            lines_inserted: lines_inserted + length? rp
>            fp: insert fp rp
>            while [all [
>                not tail? fp
>                not find first fp "end replace here"
>            ]][
>                lines_removed: lines_removed + 1
>                remove fp
>            ]
>            break
>        ]
>        fp: next fp
>    ]
>    print [lines_removed "lines removed"]
>    print [lines_inserted "lines inserted"]
>    update fp
>    close fp
>]
>
>

Reply via email to