DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

problem when accessing Diadem via OLE

Hello,
 
I've got two questions related to communcation with VC++ and Diadem via OLE.
I programmed the following lines in the Visual C++ environment
 
  ITOCommand *p_Diadem;
  p_Diadem = new ITOCommand;
  p_Diadem->CreateDispatch("DIAdem.ToCommand");
  while(!(p_Diadem->GetBInterfaceLocked()));
  _variant_t ValueT;
  
  p_Diadem->CmdExecuteSync(COleVariant("ScriptStart('V:\\Test.vbs')"));
  p_Diadem->TextVarGet("RootPropGet(\"Author\")", &ValueT);
  
  delete p_Diadem;
 
I call a script, which generates a new "Author"-description. When I step through the lines with the debugger and read back
the author (p_Diadem->TextVarGet("RootPropGet(\"Author\")", &ValueT);), ValueT includes the right description of the author.
But when I set a breakpoint at the "readback line" and run to this line without breaking before, the ValueT is undefined (,appears as {???} in the watch window).
It seems like a runtime error, when instanciating the object (CreateDispatch...).
Any idea, how to solve this problem?
 
Second question:
How I have to convert an Integer to the variant-datatype?
I wanted to transfer a parameter from C++ to a global variable in Diadem using the function
(Diadem->IntegerVarSet("Varible",_variant_t(1))), but there is a casting problem between const int and variant,
which mistake do I make?
 
kind regards,
JB
 

 

 

 


 
0 Kudos
Message 1 of 4
(3,263 Views)
Hello JB!
 
First question: Change
while(!(p_Diadem->GetBInterfaceLocked()));
to
while( p_Diadem->GetbInterfaceLocked() )
  Sleep(100);
(the ! was wrong, GetbInterfaceLocked is in my interface, sleep improves the overall performance).
 
 
Second question:
 
Just make a (long) cast. I prefer to use this expression: COleVariant((long)1)
 
 
Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 2 of 4
(3,254 Views)

Hello Matthias,

Thank you for your helpful information,

but now I get a new problem, maybeyou have got an idea to this. 

I am using the OLE interface to communicate with VC++ and Diadem.

I want to load parameters, before running a script-function.

So I decided, first run a script to declare the parameters (using

dim instructions) with command:

p_Diadem->CmdExecuteSync(COleVariant("ScriptStart('V:\\Main.vbs')"));

then I load the specific parameters with the command:

p_Diadem->CmdExecuteSync(COleVariant("MyVariable = 55")),

or

p_Diadem->IntegerVarSet("MyVariable",COleVariant(long(55)))

 

now I read back this parameters with command

p_Diadem->IntegerVarGet("MyVariable",&Value) //Value Type: _variant_t

 

but Value don't have the expected result, neither when setting the value in the script directly.

Can you tell me what's the problem?

 

Kind regards,

JB

0 Kudos
Message 3 of 4
(3,240 Views)
Hello JB!
 
See my reply to your other thread.
 
Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 4 of 4
(3,236 Views)