Link to home
Start Free TrialLog in
Avatar of Dynotoe
Dynotoe

asked on

C#, C++ ----- A question regarding Variant arrays in C#

Hi everyone,

I have a question regarding Vairiant arrays, what they are and how they are used in C#

I am looking at some software API documentation where is has this callable function listed in the document....

long CopyRetrievedDataToArray(short Period, VARIANT *DateArray, VARIANT *DowArray, VARIANT *DydmArray, VARIANT *OpenArray, VARIANT *HighArray,...etc)

My question is

1)  What is a VARIANT array?  Is it VARIANT in size?  Size meaning elements or dimentions?

2)  What can I do to call this function in C#?  How do I declare and initialize a Variant array in C# or will any type of array do?  Am I passing an array by reference in this situation?

3)  Can someone show me some example code that can do what I need so I can emulate.


Please allow me to express my gratitude in advance.

Thanks once again.

Regards,

Dynotoe
Avatar of testn
testn

1. VARIANT means variant in size and the object itself can indicate its size
2. The interface looks more like COM interface. If so, it might be easier to create .NET RCW dll using tlbimp
3. Need .dll so that I can take a look.
Avatar of Dynotoe

ASKER


:)  Hi again Testn.


I'm not sure about the COM stuff it's over my head.  However I will say that all the other functions/Properties work when called using the dll I brought into my C# project.  Yes you are right there is a dll for the API.  This is how I have access to the exposed methods of the API.

I just want to know how this passing an Array by reference works and if there is anything special I have to do because of this VARIANT thing.

If I create and declare 1 dimentional arrays without allocating memory/size will this method/function I pass them to size them?  Or do I have to create this specialized "Variant array" and pass in that?  Come to think of it it doesn't specify what type of array, i.e int[] or string[] etc.

Now is passing the in my arrays just passing by reference?  This way they can be chaneged by the method or something?  Is it also just passing the memory reference like a pointer to my arrays?  Sorry just trying to understand it better.

I don't see how I could give you the dll to look at exactly?  I can get info on it if you instruct me how to do that.


Anyway I appreciate you help once again.

Best,

Dynotoe
Okay.... I think you are using Unfair Advantage COM API I would think. If so, all you have is first go to your project and then add reference.... go to COM tab and search for CSIData Unfair Advantage Type Library. Then click at "select " and then click "OK". After that you will have a reference to that API automatically. You can browse detail of each API from object browser (View... Object Browser (CTRL+ALT+J))
Avatar of Dynotoe

ASKER

Hi Testn,

That's exactly what I'm working with  :)  Very good, how did you know that?  Do you use UA or work with financial data?

Well all that is done already... Now what do you want me to do once I'm in the Object Browser?

Best,

Dynotoe
Nah... nothing....

You can start using the API.

I don't have that install but check out the namespace listed in object browser.
then include that namespace using "using" statement after that create the API2 object and start to rock and roll
Avatar of Dynotoe

ASKER

Hi Testn,

Nah...nothing??  What do you mean?


I think you misunderstand my question.  I am already using the API in my project, meaning I have it up and running and have accessed methods from the dll already.  What I am trying to do is understand this exposed function I haven't used yet that takes aguments (by reference) that are "Variant Arrays".

I assume I have to declare these "Variant array's before I pass them into the function.  Since I have never passed an array by reference or used, declared or initialized a "Variant" array before, I need some guidance with doing this in C#.  etc.

Do you understand what I mean?


Best,

Dynotoe


Once you have add the reference, you got the api declaration in there already. So all you have to do is just refer to the document as you see in the object browser and start using it like that.
Avatar of Dynotoe

ASKER

yeah I know...

the function I wan to use looks like this...

long CopyRetrievedDataToArray(short Period, VARIANT *DateArray, VARIANT *DowArray, VARIANT *DydmArray, VARIANT *OpenArray, VARIANT *HighArray,...etc);


How do I use this Variant array in C#?  I never passed an array by reference especially a "Variant" Array.  How do I do this?

Dynotoe
Nooo..... look in the object browser for that API, you will see exactly how it 's implemented in C#
i think it should look something like

int CopyRetrievedDataToArray(byte Period, object[] DateArray, object[] DowArray, object[] DydmArray, object[] OpenArray, object[] HighArray,...etc);
Avatar of Dynotoe

ASKER

oh I....See.....let me take a look.

Dynotoe
Avatar of Dynotoe

ASKER


In the object browser, in the pane to the right I see...

CopyRetrievedDataToArray(short, out object, out object, out object, out object,...etc);

and when I highlight it this is shown below...

public abstract new System.Int32 CopyRetrievedDataToArray ( System.Int16 Period , System.Object DateArray , System.Object DOWArray , System.Object DydmArray , System.Object OpenArray , System.Object HighArray , System.Object LowArray , System.Object CloseArray , System.Object ClosingBidArray , System.Object ClosingAskArray , System.Object VolumeArray , System.Object OIArray , System.Object TotalVolumeArray , System.Object TotalOIArray , System.Object CashArray )

So...

What do I have to declare and initialize before passing it into the function?  You used for example "object[] DateArray" before passing this into the function I must declare it and initialize it first right????  What would that look like?  I've declared int[] and string[] but never an object[] before.  Can you guide me a little?

Thanks for your patience.

Where are you located?  I'm from Boston.

Best,

Dynotoe

if it says CopyRetrievedDataToArray(short, out object, out object, out object, out object,...etc); it means that you don't have to allocate anything..... you would do something like this

int period = 3;
DateTime[] DateArray;
int[] DOWArray;
...

UA.API2 obj = new UA.API2();
...

obj.CopyRetrievedDataToArray(period, out DateArray, out DOWArray,....);
ASKER CERTIFIED SOLUTION
Avatar of testn
testn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dynotoe

ASKER


Testn,

Great job once again.  Thank you very very much.

I'd love to know what experience you have with ua?  I never even told you it was API2 or IAPI2.  You knew it already.  Anyway I'd love to talk to you about it if your interested.  I have Skype and here is an eeeee mhail if you want to give me a quick shout.  Ishtomar (no space) Farza ate com(no space)cast shot nezt with d for sh and a silent z  :)

Thanks once again.  You're very patient.

Best,

Dynotoe
Again... I've never used it.... Just a guess :D