Hi,
I don't understand (probably because of my coursed english) if you have already implemented a scripting engine or not.
You could save in the object rappresenting your window a reference to compiled or source code. When the OnClick event is encoutered iside the events queque, you have only to call a simple function that executes the user defined code. Probably you have to start the scripting engine at the application initialization, and then you have only to add refernce to already generated objects inside your simble table and run the script.
For example:
Your window is defined in this way:
<App><scripts> <script id="ID1234"> <![CDATA[ #here you can store the bytecode if you want. #this is only an example print this.label+" pressed" PARENT.destroy() ]]> </script></scripts><Window size="100,200" title="Hi! :)"> <Button pos="10,20" label="press me" onclick="ID1234" /></Window></App>
this should show a simple window with a button. When clicked, it should print to stdout "press me pressed" and then the main window should close.
Now your code should looks like this (pseudo-like code
![](smile.gif)
):
if button.pressed:
script := button.code
symtab := scripting_engine.symble_table
symtab.store("PARENT", button.parent)
scripting_engine.run(script)
Now your scripting engine simply takes the code and runs it following your script definition.
Implementing a scripting engine is not so simple, but there are some tutorials on the net you can follow to start.
I hope this words will help you. bye
[edited by - darkbard on January 7, 2004 10:51:18 AM] [edited by - darkbard on January 7, 2004 10:51:54 AM] [edited by - darkbard on January 7, 2004 10:52:42 AM]