Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] .Net C# and Rebol

From: AJMartin:orcon at: 27-Sep-2003 11:49

I just got hold of Microsoft's .Net SDK (100MB!). One of the very nice things about C# (CSharp) is that the command line compiler is free and has a run time compiler built in. I've also been playing around with ToolSack's DotNet Script Host at http://www.toolsack.com/products/dotnetscripthost/ Here's an example of a very, very simplistic C# "Image Viewer" program: using System; using System.Windows; using System.Windows.Forms; using System.Drawing; public class MyForm : Form { public MyForm () { // Set the form's title. Text = "Image Viewer"; // Set the form's size. ClientSize = new Size (640, 480); // Create a menu. MainMenu menu = new MainMenu (); MenuItem item = menu.MenuItems.Add ("&Options"); item.MenuItems.Add (new MenuItem ("E&xit", new EventHandler (OnExit))); MenuItem miHelp = menu.MenuItems.Add ("&Help"); miHelp.MenuItems.Add (new MenuItem ("&About...", new EventHandler (OnAbout))); // Attach the menu to the form. Menu = menu; } // Handler for the Exit command. private void OnExit (object sender, EventArgs e) { Close (); } // Handler for the About command. private void OnAbout (object sender, EventArgs e) { MessageBox.Show ("Written by Andrew Martin.", "Image Viewer", MessageBoxButtons.OK, MessageBoxIcon.Information); } public static void Main (string[] args) { Application.Run (new MyForm ()); } } And the line required to compile it: csc /target:winexe /out:"Image Viewer.exe" /reference:System.dll /reference:System.Windows.Forms.dll /reference:System.Drawing.dll Main.cs And here's an example of DotNet script @ Script Language="csharp" using System.Windows; System.Windows.Forms.MessageBox.Show("Hello World!", "Hello", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Exclamation); The above is stored in a file with extension: .ns and can be simply clicked on to run. The other interesting thing is that C# has networking libraries built in along with native windows supports, plus printing. It would be really, really nice to have Rebol running under .NET. Failing that, it should be possible to get a C# client running that can understand a Rebol description of a user interface that's sent over a TCP connection. This would then allow Rebol to function with a native windows interface, and have printing on the client. It might even be possible for the C# client to understand Rebol/IOS, perhaps? Andrew J Martin ICQ: 26227169 http://www.rebol.it/Valley/ http://valley.orcon.net.nz/ http://Valley.150m.com/