Code Section

Top  Previous  Next

 

This section is only available to users that hold a Pro License

 

The code section allows C# code to be written directly into a script. When the script is executed, the code will be compiled and the methods written in the section will become available to the software and can be executed using the ExecCode command.

 

Only one Code Section is allowed per script, and it must be located at the end of the script otherwise an error will be thrown.

 

Command Syntax

 

If you wish to create a Code section, you simply type the word Code into the script surrounded by square brackets:

 

[Code]

lamp Note: The Code section must be the LAST section in the script. If it is not the last section, an error will be thrown

Example

 

This example demonstrates creating two custom methods that can be used within a script. The first has no parameters, the second uses two parameters to perform a simple calculation.

 

[Code]

 

public static void SayHello() 

 Console.WriteLine("Hello");

}

 

public static void MultiplyInt(int val1, int val2)

{

 Console.WriteLine((val1*val2).ToString());

}

 

See Also: ExecCode Using Clauses Helper Commands Setup Section Notification Section Catch Section Finally Section User Sections Tasks Section