Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!swrinde!newsfeed.internetmci.com!howland.reston.ans.net!plug.news.pipex.net!pipex!tube.news.pipex.net!pipex!dish.news.pipex.net!pipex!mk2!
From: dpeachey@vmark.co.uk (Dan)
Subject: Re: Evaluating code at runtime (is it possible?)
Organization: VMark Software Ltd.
Date: Wed, 14 Feb 96 09:08:43 GMT
Message-ID: <1996Feb14.090843.2602@vmark.co.uk>
X-Newsreader: Forte Free Agent 1.0.82
References: <4fqudv$35n@zip.io.org>
Sender: @vmark.co.uk
Lines: 56

slugboy@zip.io.org (Trevor Gimbel) wrote:

>Hi,

>Is it possible to evaluate and execute smalltalk code at runtime?
>I'm using VisualAge for Windows 3.0.

>We'd like to be able to use a Prolog engine to generate Smalltalk
>code and then have it executed in VisualAge.

>Can it be done and how?

>Thanks in advance,

>Trevor Gimbel
>slugboy@io.org


I don't use VisualAge,  but here's how I do it from ObjectStudio
(ENFIN Smalltalk).

1)  Assumption:  Code is generated by Prolog engine and stored in a
text file.  Code is stored as string representing a block context.

		e.g [ 'I love spaghetti' out.].

First open up a filestream on the text file:

	e.g  MyFile := Filestream file: 'code.txt'.

Read the code (assumed to be a single string)

	i.e  MyCodeString := MyFile nextString.

We cannot evaluate this yet, so:

	MyBlockOfCode := MyCodeString asBlock.

Now  	MyBlockOfCode value.

I would expect visualage to do something along the same lines.
As long as there are the following two methods:

	String>>asBlock
	BlockContext>>value (or perhaps evaluate)

then you will not have any problems.

I hope this helps.

Take Care.

Dan

My opinions are my own, and hence are allways right :-)

