开发者

I made a very basic scripting language - I want to be able to read output.

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 Text开发者_StackOverflow中文版Box 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?


This might help you out:

http://saezndaree.wordpress.com/2009/03/29/how-to-redirect-the-consoles-output-to-a-textbox-in-c/


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 Streams 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜