Solved

COM Array (CComSafeArray::MultiDimGetAt)

Posted on 2006-06-29
7
711 Views
Last Modified: 2008-01-09
I have a COM array of doubles of type CComSafeArray, say with 10 rows and 30 columns. I simply need to retrieve its elements one by one and print them out on the screen. How do I do this with MultiDimGetAt? I have read the Microsoft documentation available on the MSDN website but it's not very clear to me, and I don't know much about COM.
Thanks.
0
Comment
Question by:Rothbard
  • 5
  • 2
7 Comments
 
LVL 11

Expert Comment

by:Jase-Coder
ID: 17008437

for(int i=0; i < 10; i++)
{
    Array->GetAt(i, &Data);
    cout << Data;
}
0
 

Author Comment

by:Rothbard
ID: 17008472
What is Data in your code? Also, since our Array has two dimensions wouldn't you need MultiDimGetAt rather than GetAt?
0
 
LVL 11

Accepted Solution

by:
Jase-Coder earned 500 total points
ID: 17008479
sorry ignore the above: do

LONG Index[2];

for(int i=0; i< 10; i++)
   for(int j=0; j < 3; j++)
{
      Index[0] = i;
      Index[1] = j;
     
      Array->MultiDimGetAt(Index, Data);
      cout << Data << endl;
}
     

0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 11

Expert Comment

by:Jase-Coder
ID: 17008485
Data is declared the same as the elements in your array.
0
 
LVL 11

Expert Comment

by:Jase-Coder
ID: 17008489
In your case declare Data as double
0
 
LVL 11

Expert Comment

by:Jase-Coder
ID: 17008495
change for(int j=0; j < 3; j++) to for(int j=0; j < 30; j++)
0
 

Author Comment

by:Rothbard
ID: 17008514
Thanks!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question