Calling local functions from parse rules...
[1/3] from: carl::cybercraft::co::nz at: 29-Mar-2002 21:02
Hello all, I'm trying to write a function that does some parsing within it and the parse rules require a local function to be called, but I can't get parse to recognise the function. Here's an example of the problem... parse-this: func [blk rules /local str local-func value][ str: copy "" local-func: func [n][append str n] parse blk rules print str ] Which give this error...
>> parse-this ["abc"][set value string! (local-func value)]
** Script Error: local-func has no value ** Where: parse-this ** Near: local-func value How do I get it to recognise 'local-func without making 'local-func a global function? By using 'bind perhaps? But how? No way I've tried has worked. Also, 'value in the parse rule there becomes global...
>> ? value
VALUE is a string of value: "abc" I want that kept local to the function too. Any help appreciated... -- Carl Read
[2/3] from: rebol665:ifrance at: 29-Mar-2002 12:09
Hi Carl I am not a 'bind guru, however the following seems to work. parse-this: func [blk rules /local str local-func value][ str: copy "" local-func: func [n][append str n] parse blk bind rules 'str print str ] Patrick
[3/3] from: carl:cybercraft at: 30-Mar-2002 2:00
On 29-Mar-02, pat665 wrote:
> Hi Carl > I am not a 'bind guru, however the following seems to work.
<<quoted lines omitted: 5>>> ] > Patrick
Thanks Patrick - that did the trick. With my previous attempts I'd been giving rules to bind as a lit-word instead of just as a word. I know better now... -- Carl Read
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted