to-block bug?
[1/5] from: atruter::hih::com::au at: 14-Aug-2002 9:54
Anyone care to explain why a fails and b works even though they are
[apparently] identical?
>> a: [btn green]
== [btn green]
>> b: to-block "btn green"
== [btn green]
>> a = b
== true
>> view layout a
>> view layout b
** Script Error: green word has no context
** Where: do-facets
** Near: green
Regards,
Ashley
[2/5] from: atruter:hih:au at: 14-Aug-2002 10:12
> why a fails and b works
That should be "b" fails and "a" works.
Note also that the following function works:
to-blk: function [string] [blk] [
blk: copy []
foreach token parse string "" [append blk to-word token]
return blk
]
>> c: to-blk "btn green"
== [btn green]
>> view layout c
Regards,
Ashley
[3/5] from: brett:codeconscious at: 14-Aug-2002 10:31
Hi Ashley,
> Anyone care to explain why a fails and b works even though they are
> [apparently] identical?
Same words - different (or missing context).
> >> a: [btn green]
> == [btn green]
These words are part of global context. The processing of LOADing them gives
them this context by default. Same as using
LOAD "btn green"
> >> b: to-block "btn green"
> == [btn green]
To-block returns a block with words in it, but the words are not
automatically given a context.
> >> view layout a
> >> view layout b
> ** Script Error: green word has no context
> ** Where: do-facets
> ** Near: green
For the global context, the word GREEN is set to the value 0.255.0.
For a word to have a value, it can only be within a given context, and since
the word GREEN in b has no context it cannot have a value.
Sum up, the words in A have the same names as the words in B, but they are
different words. The words in A have a context set for them while those in B
do not have a context.
Regards,
Brett.
[4/5] from: brett:codeconscious at: 14-Aug-2002 10:37
To-word in this case is setting the word in the global context as well.
Regards,
Brett.
[5/5] from: atruter:hih:au at: 14-Aug-2002 11:21
> These words are part of global context. The processing of LOADing them
gives
> them this context by default. Same as using
>
> LOAD "btn green"
Doh! load was the answer I was looking for ... I overlooked that as I tend
to think of load in terms of files rather than strings. ;)
Regards,
Ashley