Hi PHil,

I replaced text-fx by block-fx and bind block-fx to fx's local context
before I do it:

fx: function [x] [] [
    print x
    bind block-fx 'x
    print do block-fx
]

block-fx: [x * x]

>> x: 100
== 100
>>
>> fx 2
2
4
>> fx 3
3
9


To the same thing with text-fx use: 


fx: function [x] [] [
    print x
    block-fx: make block! text-fx
    bind block-fx 'REBOL
    bind block-fx 'x
    print do block-fx
]


>> text-fx: "x * x"
== "x * x"
>> fx 3
3
9
>> fx 1
1
1
>> fx 2
2
4

;- Elan

At 06:33 PM 6/4/00 +0100, you wrote:
>Hi all,
>
>can anyone help me with this simple question about contexts
>
>Consider the following rebol program
>
>REBOL [
>    Title: "Test function definition"
>    Date: 04-Jun-2000
>    File: %fx.r
>    Purpose: "Test function definition"
>]
>
>; define fx
>fx: function [x] []
>[
>    print x
>    print do text-fx
>]
>
>; Main line
>text-fx: "x * x"
>
>x: 100
>
>fx 2
>fx 3
>
>
>even though I have passed the variable x into the function fx, when I "do"
>the string text-fx it used the value of x from the main line.
>
>How do I get the do function to take the value of x passed into the
>function.
>(I'm sure someone has told me how to this previously but I cant remember the
>answer :-(( .... )
>
>Cheers PHil
>
>
>

;- Elan >> [: - )]

Reply via email to