I have to communicate to an instrument via COM Object. Starting from a VBS example, I was bale to figure out how to do the same, of course in a much nicer GUI, in FP.
this is the VBS code:
RS = " "
ScopeId = " "
set app = CreateObject("LeCroy.XStreamDSO")
for i =1 to 3
app.Acquisition.TriggerMode = "Single"
RS = app.Acquisition.TriggerMode
Wscript.Echo "trigger mode: "&Rs
next
scopeId = app.InstrumentId
Wscript.Echo "instrument model: "&scopeId
the output:
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.
trigger mode: Single
trigger mode: Single
trigger mode: Single
instrument model: LECROY,WM820Zi-B,VEN-L000006,8.5.1
very simple, espacially the part where I read the setting and model. In VBS all vairables are Variant, but conversion is done automatically. and here is the problem I can't solve in FP: how to print out the returned value in the Variant, in this case RS.
I can send the command, I can read the Variant, but do not know how to use it in this case convert to a widestring. The returnned value is a Variant becasue it can be almost anything: real, integerl, array, string.
attached is the program
and here the key part of it:
procedure TForm1.FormCreate(Sender: TObject);
begin
app := CreateOleObject('LeCroy.XStreamDSO');
sleep(1000);
app.Measure.ClearSweeps ; // clear all acquisitions at start up
sleep(100);
end;
procedure TForm1.Label1Click(Sender: TObject);
begin
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
RS := ' ';
app.Acquisition.TriggerMode := 'Single'; // send single trigger command
RS:=app.Acquisition.TriggerMode; //supposed to return STOPPED
cnt:=cnt+1; // keep track of the trigger sent - see on scope Num Count
Label1.caption := 'Trigger pressed '+ IntToStr(cnt) + ' Times';
end;
can someone enlight me about using Variant in FP and how to acces the actual content?
thanks