Skip to main content
Skip table of contents

CSharp Scripting

Scripts can also be written in C#. This is supported on both Windows and Linux and offers much more performance over vb.net scripting on Linux.

C# scripts use the extension .cs. An example script:

VB
public object Main(object[] Parms)

{

hs.WriteLog("CSHARP","From C# script");

String s = DateTime.Now.ToString("ddd");

hs.WriteLog("C#","Day: " + s);

Console.WriteLine("hello");

return 0;

}

C# may also be used as script statements. Script statements start with an &, and C# scripts also need one other character to tell the script engine if it is a sub or a function. If the statement returns a value, then us "f", else if it does not return a value, use "s". For example, this sub simply writes to the log:

VB
&shs.WriteLog("script","hello");

This statement returns a value:

VB
&fDateTime.Now.ToString("ddd");

The scripting system knows when a script statement is C# by looking for a terminating semicolon ";". If one does not exist, it assumes either VBScript (for Windows), or VB.Net (for Linux)

C# is considerably faster on Linux than VB.Net for script statements.

Iif you need to add references to other DLL files, use the following syntax to reference a file, this example references the visualbasic DLL:

The ScriptingReferences INI entry is for vb.net only.

//css_reference Microsoft.VisualBasic.dll;

Note that you need the entire string even though it looks like its commented out.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.