In the last article, we continued to develop our version of MSH Logo. In typical software-geek fashion, we designed a train-wreck for a user interface. Rather than provide our users with the power required to make fancy graphics, we shackled them with a handful of ineffective commands. But it was all we thought the users needed! Many situations aren’t even this clear-cut. For example, the Microsoft Office System is a phenomenal suite of applications.
Robert Scoble recently asked the question, “Why Do Search Engines Lie?” He calls out that the engines are usually off by a few results - with 692 results instead of a claimed 699, 100 results instead of a claimed 101, etc. The numbers are worse when you count only “unique hits.” That gives numbers like 62 of 713, or 44 of 368. I’m sure that developers of the respective search engines could give great technical answers to his question, but it’s probably best answered rhetorically: “Who cares?
Tony has been working on a great series of posts to explore some of Monad’s security features. He provides a method to start programs using the Administrator account, without having to always type in the Administrator’s password. To do this, he uses the export-secureString cmdlet to export the password to disk, and the import-secureString cmdlet to re-import it when required. The export-secureString cmdlet, when not given an encryption key, uses Windows' Data Protection API, known more commonly as DPAPI.
Ok, so now that we’ve talked about our grand design for MSH Logo, our next task is to simply integrate this into a GUI. You can download the Visual Studio 2005 project from here. The most interesting class, by far, is our Turtle class: using System; using System.Collections.Generic; using System.Text; using System.Drawing; namespace Monad_Hosting { /// <summary> /// A turtle class that implements some of the logo primitives. /// It stores a reference to the canvas upon which it draws, and /// is responsible for drawing on that canvas.
This quick reference summarizes the useful resources available at gregg.angelfishy.net. The document puts the Gregg alphabet, and 147 brief forms all in one helpful quick reference.
As I mentioned last time, this series of articles will introduce you to some of the features of Monad’s hosting model. Before we get into the details of hosting Monad, though, we need to first lay out our conceptual framework. Our application is a simple WinForms control. It displays a small triangle (of Logo fame,) and users control movement of the turtle through a small set of commands. The turtle supports the following:
Do you have an awesome little script that you want to share with the world? A Monad administration technique so slick that you want everyone to know about it? Here’s a great chance - the opportunity to include your work in a forthcoming O’Reilly “Monad Hacks” book. As you might know, one of the great hallmarks of this series is that it includes contributions from enthusiasts worldwide. I’m continually amazed at the techniques that you all come up with.
A while back, I wrote the article, “A Web-enabled, Monad front end: Monad hosting.” It was in reference to WebCmd, a neat little Javascript application that emulates an interactive terminal. I also talked about the fact that it wasn’t really an interactive terminal. This falls quite short of the infrastructure required to support an interactive program such as VI. Let alone Emacs :) There’s no support for cursor positioning, keyboard polling, and much more.
There are some very useful parts of the .Net framework (ie: System.Web and System.Windows.Forms) that Monad doesn’t load into its AppDomain by default. In order to use them, you first load them with one of the Load() methods from the System.Reflection.Assembly class. At first, the easiest approach seems to be LoadWithPartialName. You can simply request “System.Windows.Forms” and be done with it: MSH:73 C:\temp > [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") GAC Version Location --- ------- -------- True v2.
You might remember a recent obfuscated Monad script that Adam wrote. It’s impressive, but not as obfuscated as this one! This turned up in a search I was doing – feed2podcast.com looks like an interesting idea. Thank goodness they don’t index the comments, because the spam sure is piling high there, Adam :) [Edit: Monad has now been renamed to Windows PowerShell. This script or discussion may require slight adjustments before it applies directly to newer builds.