ExecCode

Top  Previous  Next

 

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

 

The ExecCode command allows you to run C# code written in the Code Section from within the script. The code can be anything that you want to write.

lamp Important: This is very much a power user feature, which is why it is only available with a Pro License. In order to use the ExecCode command you must be an experienced programmer capable of writing raw code using the C# programming language.

Command Syntax

 

ExecCode:[MethodName],[Parameters]

 

The colon after the command is compulsory. The comma character after the executable path is only compulsory where Parameters are specified. The ExecCode command itself is not case sensitive, but parameters may be depending on the program, operating system, and locale.

 

Parameters:

 

MethodName: The name of the method to be executed which must have been written in the code section by the user

Parameters: Any parameters to the method line that may be required, separated by commas and surrounded by quotation marks if they are a string type.

 

The MethodName parameter is compulsory. The Arguments parameter may or may not be required depending upon the code being run. If any required parameter is missing or invalid an error will be thrown.

 

Supported Data Types

 

The following data types are supported for parameters:

 

Keyword

.Net Data Type

Size

Example Parameter

 

bool

System.Boolean

1 bit

true

byte

System.Byte

Unsigned 8-bit integer

1

char

System.Char

16 bit

A

datetime

System.DateTime

8 bytes

2021-06-01 00:00:00

decimal

System..Decimal

16 bytes

16.58

double

System.Double

8 bytes

100.00

float

System.Single

4 bytes

75.5

int or int32

System.Int32

Signed 32-bit integer

10

long or int64

System.Int64

Signed 64-bit integer

123456

sbyte

System.SByte

Signed 8-bit integer

1

short

System.Int16

Signed 16-bit integer

1

string

System.String

varies according to string

"This is a string"

uint

System.UInt32

Unsigned 32-bit integer

10

ulong

System.UInt64

Unsigned 64-bit integer

123456

ushort

System.UInt16

Unsigned 16-bit integer

10

 

The keywords are not case sensitive, so you can use Int64 or int64 and get the same result.

 

Examples:

 

Without Parameters:

 

The example assumes that you have already created a method in the Code Section called SayHello, like this:

 

[Test Execute Code]

 

ExecCode:SayHello

 

[Code]

 

public static void SayHello() 

    Console.WriteLine("Hello");

}

 

With Parameters:

 

The example assumes that you have already created a method in the Code Section called SayHelloWorld, like this:

 

[Test Execute Code]

 

ExecCode:SayHelloWorld,"true"

 

[Code]

 

public static void SayHelloWorld(bool languageIsGerman) 

    Console.WriteLine(languageIsGerman ? "Hallo Welt" : "Hello World");

}

lamp Note: The ExecCode command does not return a value - its purpose is purely to execute code, not to process any resulting value. Therefore it is recommended that you only use methods in the Code Section that return void, or be prepared for the fact that any return value will simply be ignored.

See Also: Code Section Reference Using Clauses Exec Run If Command GetCodeValue CodeResult