Hello, I've been beating my head on the wall on this one for a while and thought 
someone else might have a solution.  Starting with the tag parsing examples on the web 
site I've created a function to return just the text portion of a string, removing all 
HTML tags and newline characters.  However, when I call this function more than once 
in the same statement it returns the value of the last function call for each instance 
of the call!?!  The script and it's output is as follow:

;<-----Start Script----->
REBOL []
tag-parser: make object! [
        text: make string! 8000
        text-rule: [
                ["<" thru ">"] | [newline] | copy txt to "<" (append text txt)
        ]
        gettext: func [str [string!]] [
                clear text
                parse str [to "<" some text-rule]
                return text
        ]
]
blk-name: copy {<B>BLOCK</B>}
notice: copy {<U>NOTICE</U>}
frm-val: copy {From1}
to-val: copy {To1}
amt-val: copy {Amount1}
result: copy {}

append result reduce [
        tag-parser/gettext blk-name ":"
        tag-parser/gettext notice ":"
        frm-val " to " to-val " = "
        amt-val newline
]
print result
;<-----End Script----->

 From REBOL command prompt:
 >> do file:test.r
Script: "Untitled" (none)
NOTICE:NOTICE:From1 to To1 = Amount1

In this test, it returned "NOTICE:NOTICE" instead of "BLOCK:NOTICE".  If I remove one 
of the tag-parser/gettext calls in the append statement it returns the correct value, 
but one of them is left with it's HTML tags.  I encapsulated the function and it's 
variables into an object! hoping this would help but it's the same either way.

Am I missing some easy fix for this?

Thanks in advance!

->Steve Blackmore

Reply via email to