Jump to: navigation, search

Introduction to C# has been written in such a way that bespoke C# scripts can be written by the end user and will be compiled into at runtime.

This makes very versatile and with a little C# knowledge a very powerful contest logging tool.

To learn the basics about C# there are lots of free on-line help like

Microsoft have a free fully functional version of Visual Studio called Community, available from

C# Script Structure

Scripts must start with references to the relevant objects
//INCLUDE_ASSEMBLY System.Windows.Forms.dll

Each script needs to implement three methods, as shown in the example:
- Initialize
- Deinitialize
- Main

Initialize is called when the script is compiled and the object created. This is used to hook on events or initialize additional properties etc.

Deinitialize is called when the object is going to be closed, for example when we exit

Main is called each time the script is called with a defined shortcut or from a macro message.

To enable the script to communicate with the main code, references to the object are required so the command can be passed into the methods.

They are:
FrmMain - this is a reference to the main form window - from this you can access any other public object in main code and you can access public properties, methods, hook on events etc. This object has access to everything within in the main code.

ContestData - this object contains all the properties and methods to handle the currently opened log.

COMMain - this is the main communication object which is used to access everything that is configured in the "Configure interfaces" window. Here you can access radio 1 and 2 directly or any other enabled serial or parallel port object.

Important: the bespoke C# code script must be included as source code, DO NOT COMPILE
Script must be added using the scripts manager tool in

Example Scripts

Example scripts are available in the download directory

The following script is an example of a C# script which keeps the Elecraft K3 keyer speed in sync with the CW speed set in

 //INCLUDE_ASSEMBLY System.Windows.Forms.dll
 using System;
 using System.Windows.Forms;
 using CWKeyer;
     public class Script : ScriptClass
         FrmMain mainForm;
 	    public void Initialize(FrmMain main)
             mainForm = main;
             if (mainForm._cwKeyer != null)
                 mainForm._cwKeyer.CWSpeedChange += new CWKey.CWSpeedChangeDelegate(handleCWSpeedChange);
 	    public void Deinitialize()
               if (mainForm._cwKeyer != null)
                   mainForm._cwKeyer.CWSpeedChange -= handleCWSpeedChange;
         public void Main(FrmMain main, ContestData cdata, COMMain comMain)
         private void handleCWSpeedChange(int radioNumber, int newSpeed)
             CATCommon radioObject = mainForm.COMMainProvider.RadioObject(radioNumber);
             if (radioObject == null)
                 mainForm.SetMainStatusText(String.Format("CAT object for radio {0} isn't available!", radioNumber));
             radioObject.SendCustomCommand(String.Format("ks0{0};", newSpeed));
             mainForm.SetMainStatusText(String.Format("Radio {0} CW speed changed to {1} wpm!", radioNumber, newSpeed));
Personal tools