• HOME
  • PRODUCTS
  • DEMOS
  • BUY
  • BLOG
  • FORUM
  • DOCUMENTATION
  • ABOUT
  • FREE EVALUATION
Search Results for

    Show / Hide Table of Contents

    Compiled Property

    Compiled

    Gets boolean value indicating that script has been compiled and ready to be executed.

    Declaration
    [Browsable(false)]
    public virtual bool Compiled { get; }
    Property Value
    Type Description
    Boolean
    Implements
    IScriptRunBase.Compiled
    Remarks

    You can check whether ScriptRun has been already compiled before compiling the script to perform additional handling of the compilation results.

    Examples

    Here is how to use a Compiled in the C# code:

    using System.Linq;
    using System.Windows.Forms;
    
    using Alternet.Scripter;
    
    public partial class Form1 : Form
    {
        private ScriptRun scriptRun;
        private void Form1_Load(object sender, EventArgs e)
        {
            scriptRun = new ScriptRun();
        }
    
        private void RunButton_Click(object sender, EventArgs e)
        {
            scriptRun.ScriptSource.FromScriptCode(edit.Text);
            scriptRun.ScriptSource.WithDefaultReferences();
            scriptRun.AssemblyKind = ScriptAssemblyKind.DynamicLibrary;
    
            if (!scriptRun.Compiled)
            {
                if (!scriptRun.Compile())
                {
                    MessageBox.Show(string.Join("\r\n", scriptRun.ScriptHost.CompilerErrors.Select(x => x.ToString()).ToArray()));
                    return;
                }
            }
    
            scriptRun.Run();
        }
    }
    

    Here is how to use a Compiled in the Visual Basic code:

    Imports System.Linq
    Imports System.Windows.Forms
    Imports Alternet.Scripter
    
    Partial Public Class Form1
        Inherits Form
    
        Private scriptRun As ScriptRun
    
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
            scriptRun = New ScriptRun()
        End Sub
    
        Private Sub RunButton_Click(ByVal sender As Object, ByVal e As EventArgs)
            scriptRun.ScriptSource.FromScriptCode(edit.Text)
            scriptRun.ScriptSource.WithDefaultReferences()
            scriptRun.AssemblyKind = ScriptAssemblyKind.DynamicLibrary
    
            If Not scriptRun.Compiled Then
    
                If Not scriptRun.Compile() Then
                    MessageBox.Show(String.Join(vbCrLf, scriptRun.ScriptHost.CompilerErrors.[Select](Function(x) x.ToString()).ToArray()))
                    Return
                End If
            End If
    
            scriptRun.Run()
        End Sub
    End Class
    
    In This Article
    Back to top Copyright AlterNET Software Download PDF