ListOfDevices Function: Sample Code for Borland® Delphi

 

Sample Code

// Runs Available Transfer Capability Routine

// Executes ATC Calculations among all areas

// and sends results to Excel

procedure TMainForm.RunATCClick(Sender: TObject);

var

i, j, LowB, HighB : Integer; 

ValuesAreaArray : OLEVariant; 

begin

// Obtain all the areas 

Output := SimAuto.ListOfDevices('area', ''); 

if (string(Output[0]) <> '') then 

StatusBar1.Panels[1].Text := 'Error: ' + string(Output[0]) 

else 

begin 

ValuesAreaArray := Output[1][0]; 

LowB := VarArrayLowBound(ValuesAreaArray, 1); 

HighB := VarArrayHighBound(ValuesAreaArray, 1); 

// Executes loop 

for i := LowB to HighB do 

for j := LowB to HighB do begin 

if (i <> j) then begin 

// Runs ATC calculations 

OutputATC := SimAuto.RunScriptCommand('entermode(atc); ' +  

'atcdetermine([Area ' + IntToStr(ValuesAreaArray[i]) +  

'], [Area ' + IntToStr(ValuesAreaArray[j]) + '])'); 

if (string(OutputATC[0]) <> '') then 

StatusBar1.Panels[1].Text := 'Error: ' + string(OutputATC[0]) 

else begin 

// Sends ATC results to Excel 

Output := SimAuto.SendToExcel('transferlimiter', '', 'all'); 

if (string(Output[0]) <> '') then 

StatusBar1.Panels[1].Text := 'Error: ' + string(Output[0]) 

else 

StatusBar1.Panels[1].Text := 'ATC calculations done.'; 

end; 

end; 

end; 

end; 

end;