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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 How to transort data from dataset to COM class?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Hlavenka Posted - 08/04/2005 : 08:43:14 AM
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

3   L A T E S T    R E P L I E S    (Newest First)
Hlavenka Posted - 08/09/2005 : 04:25:29 AM
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
easwar Posted - 08/08/2005 : 3:33:09 PM
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

easwar Posted - 08/05/2005 : 11:49:59 AM
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


The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000