hi
I want the .net code itself to be executed as a
script.
The user enters a .net code..The whole code should
execute as  a script..

regards
gan
--- "Collins, Michael G" <[EMAIL PROTECTED]>
wrote:
> Here is some sample code I created a few days back.
> This is a WinForm application.
>
> Watch for line breaks where they don't belong.
> (Wonderfull email)
>
> Make sure you include a reference to the
> MSScriptingControl:
> 1) Right click on 'References' in the Solution
> Explorer
> 2) Click on Add Reference
> 3) Click on the COM tab
> 4) Double click on the 'Microsoft Script Control
> 1.0'
>    This will import it into your project.
> 5) Click OK
>
> Then use the code below to test it.
>
> I love how you can add .NET objects into the script
> engine by just adding
> public functions.
>
> WAY COOL!
>
> Here is my code for reference:
> ------------------------------------------
> (Form1.cs)
> ------------------------------------------
> using System;
> using System.Drawing;
> using System.Collections;
> using System.ComponentModel;
> using System.Windows.Forms;
> using System.Data;
>
> namespace ScriptTest1
> {
>         /// <summary>
>         /// Summary description for Form1.
>         /// </summary>
>         public class Form1 :
> System.Windows.Forms.Form
>         {
>                 private System.Windows.Forms.Label
> label1;
>                 private System.Windows.Forms.Button
> runButton;
>                 private System.Windows.Forms.Button
> closeButton;
>                 private System.Windows.Forms.TextBox
> sourceCode;
>                 private
> MSScriptControl.ScriptControl iscr;
>                 /// <summary>
>                 /// Required designer variable.
>                 /// </summary>
>                 private
> System.ComponentModel.Container components = null;
>
>                 public Form1()
>                 {
>                         //
>                         // Required for Windows Form
> Designer support
>                         //
>                         InitializeComponent();
>
>                         //
>                         // TODO: Add any constructor
> code after
> InitializeComponent call
>                         //
>                 }
>
>                 /// <summary>
>                 /// Clean up any resources being
> used.
>                 /// </summary>
>                 protected override void Dispose(
> bool disposing )
>                 {
>                         if( disposing )
>                         {
>                                 if (components !=
> null)
>                                 {
>
> components.Dispose();
>                                 }
>                         }
>                         base.Dispose( disposing );
>                 }
>
>                 #region Windows Form Designer
> generated code
>                 /// <summary>
>                 /// Required method for Designer
> support - do not modify
>                 /// the contents of this method with
> the code editor.
>                 /// </summary>
>                 private void InitializeComponent()
>                 {
>                         this.label1 = new
> System.Windows.Forms.Label();
>                         this.runButton = new
> System.Windows.Forms.Button();
>                         this.closeButton = new
> System.Windows.Forms.Button();
>                         this.sourceCode = new
> System.Windows.Forms.TextBox();
>                         this.SuspendLayout();
>                         //
>                         // label1
>                         //
>                         this.label1.BackColor =
> System.Drawing.SystemColors.Window;
>                         this.label1.BorderStyle =
> System.Windows.Forms.BorderStyle.FixedSingle;
>                         this.label1.FlatStyle =
> System.Windows.Forms.FlatStyle.Flat;
>                         this.label1.Location = new
> System.Drawing.Point(8,
> 184);
>                         this.label1.Name = "label1";
>                         this.label1.RightToLeft =
> System.Windows.Forms.RightToLeft.No;
>                         this.label1.Size = new
> System.Drawing.Size(448,
> 216);
>                         this.label1.TabIndex = 0;
>                         //
>                         // runButton
>                         //
>                         this.runButton.Location =
> new
> System.Drawing.Point(8, 152);
>                         this.runButton.Name =
> "runButton";
>                         this.runButton.TabIndex = 1;
>                         this.runButton.Text = "Run";
>                         this.runButton.Click += new
> System.EventHandler(this.runButton_Click);
>                         //
>                         // closeButton
>                         //
>                         this.closeButton.Location =
> new
> System.Drawing.Point(384, 152);
>                         this.closeButton.Name =
> "closeButton";
>                         this.closeButton.TabIndex =
> 2;
>                         this.closeButton.Text =
> "Close";
>                         this.closeButton.Click +=
> new
> System.EventHandler(this.closeButton_Click);
>                         //
>                         // sourceCode
>                         //
>                         this.sourceCode.AcceptsTab =
> true;
>                         this.sourceCode.AllowDrop =
> true;
>                         this.sourceCode.Location =
> new
> System.Drawing.Point(8, 8);
>                         this.sourceCode.Multiline =
> true;
>                         this.sourceCode.Name =
> "sourceCode";
>                         this.sourceCode.ScrollBars =
> System.Windows.Forms.ScrollBars.Both;
>                         this.sourceCode.Size = new
> System.Drawing.Size(448,
> 136);
>                         this.sourceCode.TabIndex =
> 3;
>                         this.sourceCode.Text = "var
> out = \"\";\r\nout =
> \"hello from jscript\\r\\n\";\r\n\r\nfor( i = 0; i <
> 10; i++ )\r\n{\r\n\t" +
>                                 "out += \"This is
> the output for line:
> \"+(i+1)+\" -
> [\"+obj.Add(i,i)+\"]\"+\"\\r\\n\";\r\n}\r" +
>                                 "\n\r\ntest.Write(
> out );\r\ntest.Alert(
> \"This is a popup!\" );";
>                         this.sourceCode.TextChanged
> += new
> System.EventHandler(this.sourceCode_TextChanged);
>                         //
>                         // Form1
>                         //
>                         this.AutoScaleBaseSize = new
> System.Drawing.Size(5,
> 13);
>                         this.ClientSize = new
> System.Drawing.Size(464,
=== message truncated ===


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to