Elan - thank you.  You'd think with some C programming experience I would have thought 
about the scope of the variable.  For some reason it's taking a while for the REBOL 
language concepts to sink in ;-)  All of the solutions you suggested worked great.  
Again thank you.

 >S<

At 05:45 PM 1/20/00 -0800, [EMAIL PROTECTED] wrote:
>Hi Steve,
>
>the reason you get this result is that your gettext function returns a
>reference to the string 'text which is defined in your tag-parser object.
>
>This 'text string is created exactly once, namely when the object is created. 
>
>Each time your parse-rule evaluates (append text txt), the string
>referenced by txt is appended to the (cleared) string referenced by text. 
>
>When you change the content of the string referenced by 'text in the
>tag-parser object, you have changed the data being referenced by all
>references to the 'text string. including the reference appended to 'result
>in the line
>
>append result reduce [
>
>What you can do about it:
>
>you can either return a copy of text from gettext, instead of returning the
>refernce itself:
>
>change this:
>
>                 return text
>
>to this:
>               return copy text
>
>or replace the clear text expression in gettext to making the 'text string
>and kick the 'text string from the object altogether:
>
> >tag-parser: make object! [
> >       text: make string! 8000       <====== remove this
>
>
> >gettext: func [str [string!]] [
> >               clear text             <======= replace this
>
>gettext: func [str [string!] /local text] [
>               text: make string! 8000    <===== by this
>
>or 
>
> >tag-parser: make object! [
> >       text: make string! 8000       <====== replace this
>
>tag-parser: make object! [
>         text: none                    <====== by this
>
>and
> >gettext: func [str [string!]] [
> >               clear text             <======= replace this
>
>gettext: func [str [string!] /local text] [
>               text: make string! 8000    <===== by this
>
>
>
>At 04:46 PM 1/20/00 -0600, you wrote:
> >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
> >
> >
> >
>
>;- Elan >> [: - )] 

Reply via email to