Thanks Ken. Works like a charm.
On Sep 8, 2006, at 2:04 AM, Ken Ferry wrote:
> On 9/7/06, Jeremy Sacket <js...@ga...> wrote:
>>
>> I am trying to implement extensions into my app. I am wanting to
>> define
>> blocks in one file and then run only blocks that I call.
>> Example:
>>
>> [
>> name:=[ sys log:('Jeremy').]
>> description:=[ :des| sys log:('des).]
>> ]
>>
>> Now I want to just execute the "name" block.
>
> Executing the big outer block will dump a definition for 'name' and
> 'description' in the enviroment that executes the block. Executing
> the outer block will not execute the inner blocks. So, you could do
> this:
>
> (typed in gmail, and skipping all the error handling for conciseness.
> Note that the example string above won't compile as a block.)
>
>> -(id)runProcedure
>> {
>> // will set fscript to the above example.
>> NSString *fscript = [procedure objectForKey:@"procedure"];
>
> FSInterpreter *interpreter = [FSInterpreter interpreter];
> System *sys = [interpreter objectForIdentifier:@"sys" found:NULL];
> Block *outerBlock = [sys blockFromString:fscript]; // block is
> compiled in the environment of the interpreter
> [outerBlock value]; //.. so the 'name' identifier is bound in the
> interpreter
> Block *nameBlock = [interpreter objectForIdentifier:@"name"
> found:NULL];
> [nameBlock value];
> }
>
> It might seem a little less indirect if the file contained statements
> without the big enclosing block. Then you could use -[FSInterpreter
> execute:] to execute the string, and -[FSInterpreter
> objectForIdentifier:found:] to retrieve the blocks bound in the
> interpreter as a result.
>
> -Ken
>
> ----------------------------------------------------------------------
> ---
> Using Tomcat but need to do more? Need to support web services,
> security?
> Get stuff done quickly with pre-integrated technology to make your
> job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache
> Geronimo
> http://sel.as-us.falkag.net/sel?
> cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> F-Script-talk mailing list
> F-S...@li...
> https://lists.sourceforge.net/lists/listinfo/f-script-talk
|