Salesforce

How Do I Send and Retrieve Array Values from COM Objects? (Magic xpa 4.x)

« Go Back

Information

 
Created BySalesforce Service User
Approval Process StatusPublished
Objective
Description

How Do I Send and Retrieve Array Values from COM Objects? (Magic xpa 4.x)

You can see some of the real power of Magic xpa and COM objects when you start working with arrays and COM objects. In the example shown above, we processed a table and moved it into an Excel spreadsheet, using only a few lines of code.

You pass a vector to and from a COM object just as you would pass any other parameter. You do need to know approximately what the COM object is expecting or sending in terms of whether the data is numeric or alpha, but you don’t need to worry about the details (whether the number is Float or Long, for example).

You also may need to make allowances for how many items there are in the vector. In this example, for instance, we used Counter(0) to keep track of how many customers were in the table, so we could allocate the correct number of cells in the Excel worksheet.

Passing an array to a COM object

  1. First, set up your vector. In this example, we are using a two-dimensional array, where each line is one-dimensional array containing the customer number and customer name.



    The first vector is just a string array. When it is full, it contains two elements: the customer number (as a string) and the customer name (also a string). This corresponds to one horizontal row in the spreadsheet.

    The second vector is a vector where each row is using the model of the first vector. This corresponds to the entire spreadsheet.


  2. Next, since we are passing a vector into the COM object, we fill the vector up with data, using the VecSet() function.


  3. After the vector is set up, passing it in is easy. The vector is simply passed in as any variable would be.

Reference
Attachment 
Attachment