Table of Contents

Property Compiled

Namespace
Alternet.Scripter.IronPython
Assembly
Alternet.Scripter.IronPython.v9.dll

Compiled

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

[Browsable(false)]
public virtual bool Compiled { get; }

Property Value

bool

Examples

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

using System.Linq;
using System.Windows.Forms;

using Alternet.Scripter.IronPython;

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);

        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.IronPython

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)

        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

Remarks

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