The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 How to transort data from dataset to COM class?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Hlavenka

Czech Republic
Posts

Posted - 08/04/2005 :  08:43:14 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): OriginPro 7.5
Operating System: XP SP2

Hi,
I'd like to make some calculation on dataset(s) in a COM class. I can easily get single values (not array) into and from the COM class, but I was not able to call a function with array as a parameter (but I was able to return array and asign it to a Dataset).

The COM class is written in C# in VS2003. Do you have any experiences with .NET (via COM interop) called from OC?
Is there any manual (HowTo or FAQ) for using COM in different way than just open graph in Word/Excel?
Thank you for helping me
Peter

Here is the C# code (part of it):

public class TestClass {
public TestClass(){} //constructor
public double SetGetDoubleProc(double f){ //this works fine
return f*1.0;
}
[return: MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)]
public double [] GetArrTest()
{
double[] arr =new double[4];
arr[0]=5.5; arr[3]=0.05;
return arr;
}
public double Avr([MarshalAs(UnmanagedType.LPArray,
SizeParamIndex=1)] double[] data,int length)
{
double avr = 0;
for(int i=0; i<length; i++)
{
avr += data[i];
}
return avr/length;
}
}


//folowing C# code works fine when called from OC, like:

object TestInterop;
TestInterop = CreateObject("TestInterop.TestClass");
double ret;
ret = TestInterop.SetGetDoubleProc(15.0); //works fine
double vv[] = {1,1,3,3};
Dataset v("Data1_A");
v.SetSize(4);
v = TestInterop.GetArrTest(); //works fine
ret = TestInterop.Avr(vv,4); //Runtime error: COM error: No such interface supported

easwar

USA
1965 Posts

Posted - 08/05/2005 :  11:49:59 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

It is defintely possible to communicate from a dot net application with Origin.

With regards to your specific question, can you please send your entire code segment to tech@originlab.com and in the message please refer to this forum post?

Thanks,

Easwar
OriginLab

Go to Top of Page

easwar

USA
1965 Posts

Posted - 08/08/2005 :  3:33:09 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Hlavenka,

Thank you for sending your code to us.

In order to put array of double into a worksheet column, you need to first set the Column Format to Numeric and also make sure that the Data Type is set to double. You can do this by double-clicking on the column header in GUI to bring up the Worksheet Column Format dialog to set these properties. Once the properties have been set, you could save the worksheet as a template and then at later times create a new worksheet from the saved template thus ensuring that the column type is set correctly before pushing in the data.

The reason this needs to be done is because default column type in Origin worksheet is Text & Numeric, which allows mixed numbers and text, and this format is not contiguous in memory. Need to set to Numeric to be contiguous to put array of data.

Easwar
OriginLab

Go to Top of Page

Hlavenka

Czech Republic
Posts

Posted - 08/09/2005 :  04:25:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Easwar,
You didn't fully understand my problem. The problem is not:

Dataset dd(4);
dd = NetCode.SomeMethodThatReturnsArray();

but the problem is to pass an array as an argument to a method:

NetCode.MethodWithArrayInArgument(dd);

I've allready posted an e-mail to Andrew explaining this in more detail.
Problem is that I have no idea, how you translate the calls form OC to COM, so I don't know how to shape the data.
Thanks for helping me.
Peter
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000