Hy all, I worder if there's something like this: Block fromString: aString in Squeak, like the example below taken from SmallTalk/X programmers guide.
|s b|
s := '[:a :b | (a squared + b squared) sqrt ]'. b := (Block fromString:s). Transcript showCR:(b value:3 value:4)
I need to get a Block of code from an input field like TextMorph in a GUI. I haven't found nothing like this in my squeak-dev image 3.10. Is there another way to obtain am evaluable Block of code from a string? Many thanks
On 24.05.2008, at 12:47, Davide Arrigo wrote:
Hy all, I worder if there's something like this: Block fromString: aString in Squeak, like the example below taken from SmallTalk/X programmers guide.
|s b|
s := '[:a :b | (a squared + b squared) sqrt ]'. b := (Block fromString:s). Transcript showCR:(b value:3 value:4)
I need to get a Block of code from an input field like TextMorph in a GUI. I haven't found nothing like this in my squeak-dev image 3.10. Is there another way to obtain am evaluable Block of code from a string?
| s b | s := '[:a :b | (a squared + b squared) sqrt ]'. b := Compiler evaluate: s. Transcript show: (b value: 3 value: 4); cr.
This will work for any expression in a String, not just blocks.
- Bert -
..........
|s b|
s := '[:a :b | (a squared + b squared) sqrt ]'. b := (Block fromString:s). Transcript showCR:(b value:3 value:4)
I need to get a Block of code from an input field like TextMorph in a GUI. I haven't found nothing like this in my squeak-dev image 3.10. Is there another way to obtain am evaluable Block of code from a string?
| s b | s := '[:a :b | (a squared + b squared) sqrt ]'. b := Compiler evaluate: s. Transcript show: (b value: 3 value: 4); cr.
This will work for any expression in a String, not just blocks.
- Bert -
Great!! many thanks Bert it work fine. Best regards
beginners@lists.squeakfoundation.org