Creating C# scripts
Importing external modules
The search path for importing C# modules can be extended in the script itself, for example:
Example:
#r "C:\\Program Files\\Microsoft SQL Server\\120\\SDK\\Assemblies\\Microsoft.SqlServer.Smo.dll" |
Importing and using ScriptoMate Types
Example:
//ScriptoMate types //VSApi is already loaded in ScriptoMate by default, only one using statement required using VSApi; //Other types #r "System.Windows.Forms" |
Accessing Host objects
Please refer to the Scripting Host Object Model
Most common uses
//Set property //Call a sub routine ScriptData.Variables.Remove("Test"); //Call a function string err = IsRuntimeError().ToString(); //Create object string varName = "new_var"; //Datatable.RepeatScript //DR_TRX is the Datarow set by the repeater DataRow dr = (DataRow) ScriptData.Variables["DR_TRX"].Value; |
Misc.RunScript examples
Host Object |
Example file |
Host.ScriptData.Variables |
Xml\Tutorial\5001 Advanced topics\0401 Creating scripts\CSharp.Variables.xml |
Host.ScriptData.MailServers |
Xml\Tutorial\5001 Advanced topics\0401 Creating scripts\CSharp.MailServers.xml |
Host.ScriptData.FtpServers |
Xml\Tutorial\5001 Advanced topics\0401 Creating scripts\CSharp.FtpServers.xml |
Host.Progress |
Xml\Tutorial\5001 Advanced topics\0401 Creating scripts\CSharp.Progress.xml |
Host.DatasetManager |
Planned |
Host.AppManager |
Xml\Tutorial\5001 Advanced topics\0401 Creating scripts\CSharp.Application.xml |
Datatable.RepeatScript examples
Host Object |
Example file |
Host.ScriptData.Variables |
Xml\Tutorial\5001 Advanced topics\0401 Creating scripts\Datatable.RepeatScript.CSharp.xml |