Using an array in .Net with the Classic API

Post Reply
Motyl
Posts: 51
Joined: Wed Oct 09, 2013 2:29 pm
OLAP Product: Cognos
Version: 10.1
Excel Version: 2010

Using an array in .Net with the Classic API

Post by Motyl »

I have same problem with truncating an array:

Code: Select all

long[] elementArray = new long[2];

int a =TM1API.TM1ObjectListHandleByNameGet(hPool, hServer,TM1API.TM1ServerDimensions(), TM1API.TM1ValString(hPool, "Sklepy", 100));
int b = TM1API.TM1ObjectListHandleByNameGet(hPool, a, TM1API.TM1DimensionElements(), TM1API.TM1ValString(hPool, "101", 100));


int c = TM1API.TM1ObjectListHandleByNameGet(hPool, hServer, TM1API.TM1ServerDimensions(), TM1API.TM1ValString(hPool, "Miara - Parametry ATS dla Salonow", 100));

int d = TM1API.TM1ObjectListHandleByNameGet(hPool, c, TM1API.TM1DimensionElements(), TM1API.TM1ValString(hPool, "Aktywny", 100));
            
elementArray[0] = b;
elementArray[1] = d;
            

int    hCube = TM1API.TM1ObjectListHandleByNameGet(hPool, hServer, TM1API.TM1ServerCubes(),TM1API.TM1ValString(hPool, "Salony ATS", "Salony ATS".Length ));

MessageBox.Show(elementArray.Length.ToString()); -- Two
int hEACapsule = TM1API.TM1ValArray(hPool, ref  elementArray,  2);
MessageBox.Show(elementArray.Length.ToString()); -- One
Alan Kirk
Site Admin
Posts: 6667
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: Using an array in .Net with the Classic API

Post by Alan Kirk »

Motyl wrote:I have same problem with truncating an array:

Code: Select all

long[] elementArray = new long[2];

int a =TM1API.TM1ObjectListHandleByNameGet(hPool, hServer,TM1API.TM1ServerDimensions(), TM1API.TM1ValString(hPool, "Sklepy", 100));
int b = TM1API.TM1ObjectListHandleByNameGet(hPool, a, TM1API.TM1DimensionElements(), TM1API.TM1ValString(hPool, "101", 100));


int c = TM1API.TM1ObjectListHandleByNameGet(hPool, hServer, TM1API.TM1ServerDimensions(), TM1API.TM1ValString(hPool, "Miara - Parametry ATS dla Salonow", 100));

int d = TM1API.TM1ObjectListHandleByNameGet(hPool, c, TM1API.TM1DimensionElements(), TM1API.TM1ValString(hPool, "Aktywny", 100));
            
elementArray[0] = b;
elementArray[1] = d;
            

int    hCube = TM1API.TM1ObjectListHandleByNameGet(hPool, hServer, TM1API.TM1ServerCubes(),TM1API.TM1ValString(hPool, "Salony ATS", "Salony ATS".Length ));

MessageBox.Show(elementArray.Length.ToString()); -- Two
int hEACapsule = TM1API.TM1ValArray(hPool, ref  elementArray,  2);
MessageBox.Show(elementArray.Length.ToString()); -- One
I've split this off from my Connecting To TM1 Using VB.Net and the *CLASSIC* API post for multiple reasons. First, I don't want it becoming a "catch all" thread for any API related questions. Second it's way, way off topic since I made it clear at the outset that while I may dabble in it occasionally, I don't "do" C#. The post was about VB.Net. And the code above is NOT VB.Net, as one glimpse at the array operators tells us.

I have no idea what you're trying to achieve above, but as to your specific question my guess, bearing in mind again that I haven't used the C side of the API operationally including this specific function, would be this part of the documentation:
The function returns the handle to the array value capsule created. The array has no values. You must add values to the array with the function TM1ValArraySet.
Putting the handles that you derive from TM1ObjectListHandleByNameGet into the array elements before you call TM1ValArray ain't quite the same thing, I think.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
Post Reply