ADO Example
The following code is an example of how to create a ADO with the custom tool scripting.
//
// Sample script for Optuma tool programming
//
// This section is where variable are defined that need to be used in both the Init and Process procedures
// DefineTool is where the settings for the Tool are defined
// This procedure is called once when the tool is loaded
// Normally this procedure does not need to be changed
procedure DefineTool(Tool : TTool);
begin
Tool.Name := 'ado';
Tool.Key := '210189E5-77AF-4616-B5A1-04829030C11E';
Tool.MouseClicks := 1;
Tool.Hint := 'ado com example';
Tool.ToolType := ttDataList;
end;
// Init is called to initialise the tool
// This procedure is called once when the tool is added to a chart
procedure Init(Tool : TTool);
var
ObjConnC, ObjRSC : Variant;
myDSN : String;
mySQL : String;
i : Integer;
fld : variant;
aText : TText;
begin
Tool.ShowInPropertiesPanel := False;
ObjConnC := CreateOleObject('ADODB.Connection');
ShowMessage('ADO connection created');
myDSN := 'Driver={Microsoft Access Driver (*.mdb)};DBQ=countries.mdb';
ObjConnC.Open(myDSN);
ShowMessage('ADO connection opened');
ObjRSC := CreateOleObject('ADODB.RecordSet');
mySQL := 'SELECT * FROM COUNTRIES';
ObjRSC.ActiveConnection := ObjConnC;
ObjRSC.Open(mySQL);
i := 0;
while (ObjRSC.Eof = False) do
begin
{ get the field }
fld := ObjRSC.Fields('COUNTRY');
{ add field value to combobox }
aText := Tool.AddText(fld.value, now(), 50+i);
{ count nr. of items added }
i := i + 1;
ObjRSC.MoveNext;
end;
ShowMessage('Added '+inttostr(i)+' records');
ObjRSC.Close;
ObjConnC.Close;
end;
// Process is called to calculate and drawn the tool on screen
// This procedure is called when new data is received or loaded and
// when a selection point is moved by the user
procedure Process(Tool : TTool; ProcessStart : Integer; ProcessEnd : Integer; DataIn : TDataList);
begin
end;