Reputation: 5550
I made a very basic scripting language, and in my language there is a command called print
- or in other words - print _k
should somehow show _k
to the user.
I was using MessageBox.Show
till now but I also want to include a debugger for my language and for other reasons, I want to use a Stream
or something like it.
Basically, on the main form I wanna have a TextBox
or something that is somehow connected to a Stream
, and when (in script, on a different thread) print something
is called it will raise an event on my form that will write something
on my TextBox
.
I used to overcome this problem by sending the TextBox
object as a parameter, but I want to make it more dynamic (so I could read data in more ways than TexBox
).
Unfortunately, Stream
doesn't have any events I can use.
Maybe there is another dynamic way?
Upvotes: 0
Views: 146
Reputation: 21712
Congratulations on building a scripting language; I did that once and it was one of the most fun and productive things I worked on. Your instincts to provide a debugger and to use streams rather than strings or files are good ones.
It is difficult to suggest how to approach you specific problem because you provide no code, so we have to guess. I handled that situation by passing Stream
s in all APIs, and handled text boxes by converting the textbox text to a MemoryStream
, and using StreamReader
in the scripting engine.
As an aside, The Code Project had an outstanding series on creating a scripting language called ConScript, complete with an IDE including a debugger. I got a lot of ideas out of that series.
Upvotes: 0
Reputation: 17960
This might help you out:
http://saezndaree.wordpress.com/2009/03/29/how-to-redirect-the-consoles-output-to-a-textbox-in-c/
Upvotes: 1