A simple script that you can execute consists of at least one public class with at least one function. This function always has to be marked with the [Start] attribute.
The overall structure of a simple C# script thus looks like this:
public class <ScriptName> { [Start] public void <FunctionName> { //<Enter your code text here> return; } }
The following example shows a very simple script in C#:
public class SimpleScript { [Start] public void MyFunction() { MessageBox.Show("MyFunction was called!", "SimpleScript"); return; } }
In this example the class SimpleScript with the function MyFunction is generated. The function is marked by the [Start] attribute. If the script is executed by the menu items Utilities > Scripts > Run, the MyFunction was called! message appears.
The same example in Visual Basic.Net looks like this:
Public Class SimpleScript <Start> _ Public Sub MyFunction() MessageBox.Show("MyFunction was called!", "SimpleScript") Return End Sub 'MyFunction End Class 'SimpleScript
A script can also contain more than one function and different classes. In any case, exactly one function must be identified by the [Start] attribute.
See also