Hi Ryan,
 
I don't see any problem with the FOR loop.
 
It looks like what you're trying to do is to read in a text file, surround
each line from the third one to the end by <P> </P> tags, and join all the
paragraphs you've created into a long string.
 
The problems that appear to me are:
 
    load %news.txt
 
is going to give you a block of all the REBOL values in %news.txt - and is
going to give you an error as soon as it hits something it can't parse in the
REBOL language. You should use READ or READ/LINES instead of LOAD.
 
If you use a tag as the first argument to JOIN, you'll get a funny-looking
tag as a result. You could just use the string form of the tag, or begin with
a string such as NEWLINE so that it's easy to display the results.
 
It looks like you've got three arguments to JOIN - paragraph_end is going to
get ignored. For many values, use REJOIN followed by a block containing
all the things you want to join together.
 
It looks like you're trying to get the add_tags'th line (or paragraph?) of
article with [ article add_tags ]. If article holds a block and you want the
add_tags'th element, you need to use
 
    article/:add_tags  ; or
    pick article add_tags
 
As far as I can see, you're doing something like:
 
>> join paragraph_begin [[A block with words] 3]
== <PA block with words3>
 
Now here is what I would do. Assuming you've got one paragraph to a line,
and you want to make HTML code for that:
 
file-to-html: func [
    {Convert lines in a text file into HTML paragraphs}
    file [file!]          "text file"
    first-line [integer!] "line number to begin from"
    /local line-block news-page article-length
][
    line-block: read/lines file
    news-page: copy ""
    article-length: length? line-block
    for add-tags 3 article-length 1 [
        append news-page rejoin [ "^/" <P> line-block/:add-tags </P> ]
    ]
    news-page
]
 
With this I get:
 
>> print file-to-html %news.txt 3
 
<P>This is the third line</P>
<P>This is the fourth line</P>
<P>This is the fifth line</P>
<P>This is the sixth line</P>
<P>This is the seventh line</P>
<P>This is the eighth line</P>
 
I'm no expert on generating HTML, though. I'm sure there are lots of better
ways to do it.
 
Hope it helps,
Eric

Reply via email to