CodeResult |
Top Previous Next |
This condition is only available to users that hold a Pro License
The CodeResult condition allows you to run C# code written in the Code Section from within the script and act upon the result that the code returns. The code can be anything that you want to write as long as it returns a boolean value. 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 CodeResult condition you must be an experienced programmer capable of writing raw code using the C# programming language. Command Syntax
CodeResult:[MethodName],[Parameters]
The colon after the command is compulsory. The comma character after the MethodName is only compulsory where Parameters are specified. The CodeResult validation 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 string values.
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:
The keywords are not case sensitive, so you can use Int64 or int64 and get the same result.
Example:
This example assumes that you have already created a method in the Code Section called NumberIsEven:
[Test Code Result Condition]
If:CodeResult:NumberIsEven,2,Remark:"Number is Even",Remark:"Number is Odd"
[Code]
public static bool NumberIsEven(int value) { return value%2 == 0 ? true : false; } Note: The CodeResult condition must always return a boolean value. If you try to use a method that does not provide a boolean return value then it is likely that you will get either an error or unexpected results depending on the code you have written in the script. See Also: Code Section Reference Using Clauses Exec Run If Command ExecCode GetCodeValue |