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

.Net C# and Rebol

 [1/6] 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/

 [2/6] from: brett:codeconscious at: 27-Sep-2003 10:29


Andrew Martin wrote:
> The other interesting thing is that C# has networking libraries built in > along with native windows supports, plus printing.
How does one use the printing for reports? Is it at the level of calls to TextOut, Draw, etc on a canvas or are there higher level reporting functions?
> It would be really, really nice to have Rebol running under .NET.
I still wonder whether REBOL is a language or a virtual machine that we build our languages upon or both (no distinction), so trying to run REBOL on .Net might mean emulation ie slow.
> 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.
Ahh printing. :^)
> It might even be possible for the C# client to understand Rebol/IOS, > perhaps?
Maybe that sort of intefacing should be at a higher level (webservices) ? Regards, Brett.

 [3/6] from: AJMartin:orcon at: 27-Sep-2003 19:38


Hi, Brett. You wrote:
> How does one use the printing for reports? Is it at the level of calls to
TextOut, Draw, etc on a canvas or are there higher level reporting functions? Here's an example from MSDN: // C# private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { e.Graphics.FillRectangle(Brushes.Blue, new Rectangle(100, 150, 250, 250)); } And printing text: // C# private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { e.Graphics.DrawString("SampleText", new Font("Arial", 80, FontStyle.Bold), Brushes.Black, 150, 125); } It's sort of in between your two levels. Here's the URL for the Graphics Members of the Graphics class: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdrawinggraphicsmemberstopic.asp The page above mentions "Compositing". I don't know if it's better or worse than Rebol's compositing.
> I still wonder whether REBOL is a language or a virtual machine that we
build our languages upon or both (no distinction), so trying to run REBOL on .Net might mean emulation ie slow. That could be true. One can view the text of a Rebol script as if it were a machine. I think that simple parser that could read 'save-d Rebol block! values is possible in C# .net, which would then allow me to have a native client application communicating with Rebol on a server with Rebol dialect values. Maybe Rugby or it's successor (I can't remember it's name) might be a good idea here?
> > It might even be possible for the C# client to understand Rebol/IOS,
perhaps?
> Maybe that sort of interfacing should be at a higher level (webservices) ?
I'd like to see simple Rebol values flowing backwards and forwards across the communications link, in a dialect of some kind. Andrew J Martin ICQ: 26227169 http://www.rebol.it/Valley/ http://valley.orcon.net.nz/ http://Valley.150m.com/

 [4/6] from: AJMartin:orcon at: 27-Sep-2003 19:53


> Ahh printing. :^)
And after a bit more searching, I found this article: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vbcode/html/vbtskCodeExampleDrawingTextOnForm.asp which shows how to print reports. Which is a bit more advanced. :) Andrew J Martin ICQ: 26227169 http://www.rebol.it/Valley/ http://valley.orcon.net.nz/ http://Valley.150m.com/

 [5/6] from: bry:itnisk at: 27-Sep-2003 16:47


> It might even be possible for the C#
client to understand Rebol/IOS,
> perhaps? >
Well if you had a rebol script for generating/consuming at least some msil then you should be at the first step of working with .Net: as per Mercury: http://www.cs.mu.oz.au/research/mercury/maili ng-lists/mercury-developers/mercury- developers.0009/0268.html however for making interactions between .Net and other languages I prefer CodeDom: http://www.15seconds.com/issue/020917.htm http://www.mondrian- script.org/codedom/index.html

 [6/6] from: robert::muench::robertmuench::de at: 27-Sep-2003 17:56


On Sat, 27 Sep 2003 11:49:30 +1200, A J Martin <[AJMartin--orcon--net--nz]> wrote:
> I just got hold of Microsoft's .Net SDK (100MB!).
Hi, new versions of Windows will have it pre-installed. So expect this .NET stuff to flood the world.
> It would be really, really nice to have Rebol running under .NET.
If RT is going to think out a way to connect the interpreter to the runtime system, this would be a killer! With this is would be possible to call libraries done in other languages. As .NET ensures, that all languages compiled into the intermediate runtime language, can call each other, this should be possible. The hard part might be to do it from an interpreter on-the-fly. -- Robert M. Münch Management & IT Freelancer Mobile: +49 (177) 245 2802 http://www.robertmuench.de