Passing Array of string to component 
Author Message
 Passing Array of string to component

Hi.

I want to pass array of string to my component method.
The component method is implemented as follows :

STDMETHODIMP CCatalogService::PutDatabaseNames(VARIANT FAR*
pStringArray)
{
 // TODO: Add your implementation code here
 SAFEARRAY FAR* pSA = NULL;
 BSTR HUGEP* pBSTR;
 HRESULT hr;
 LONG cElements, lLBound, lUBound;

 if(V_VT(pStringArray) != (VT_ARRAY | VT_BSTR)) {
  return E_FAIL;
 }
 pSA = V_ARRAY(pStringArray);

 long dim = SafeArrayGetDim(pSA);
 if(dim != 1)
  return E_FAIL;

 hr = SafeArrayGetLBound(pSA, 1, &lLBound);
 if(FAILED(hr))
  return E_FAIL;
 hr = SafeArrayGetUBound(pSA, 1, &lUBound);
 if(FAILED(hr))
  return E_FAIL;

 hr = SafeArrayAccessData(pSA, (void HUGEP* FAR*)&pBSTR);
 if(FAILED(hr))
  return E_FAIL;

 cElements = lUBound - lLBound;

 ...

 hr = SafeArrayUnaccessData(pSA);
 if(FAILED(hr))
  return E_FAIL;

 return S_OK;

Quote:
}

In Visual Basic code, array of string is passed well.
Private Sub Command1_Click()
    Dim dbName As Variant
    ReDim dbName(3) As String

    For n = 0 To 3
        dbName(n) = "string" & Int(n)
    Next n

    oSearch.PutDatabaseNames(dbName)

End Sub

However, in my Javascript code I would pass an array of string as
follows
  var dbName = new Array(2);
  dbName[0] = "testdb";
  dbName[1] = "testdb2";
  oSearch.PutDatabaseNames(dbName);

But it is passed as IDispatch in the my component code i.e.
V_VT(pStringArray) is not (VT_ARRAY | VT_BSTR) but VT_DISPATCH.

How can I pass array of string to component in Javascript Code.

  skchoi.vcf
< 1K Download


Tue, 11 Feb 2003 09:19:55 GMT  
 Passing Array of string to component


Quote:
> Hi.

> I want to pass array of string to my component method.
> The component method is implemented as follows :

Hey,

Check out http://www.netspace.net.au/~torrboy/code/jsafearr/

Peter

--
Peter J. Torr - Microsoft Windows Script Program Manager

Please do not e-mail me with questions - post them to this
newsgroup instead. Thankyou!



Tue, 11 Feb 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. passing array as parameter to activex component

2. Passing Arrays between ASP/VBScript and ActiveX Components...

3. Passing arrays from ASP To VB-components...need help

4. passing array as parameter to activex component

5. Passing Arrays to COM Components

6. Passing array to COM component

7. Passing Arrays between ASP/VBScript and ActiveX Components...

8. Passing array of strings from ASP (JScript) to ATL COM

9. Passing Array of Java Strings to VBScript

10. Passing String arrays from Java to JavaScript ?

11. Funny passing a text string from a database field to a Javascript global array

12. Passing Arguments / Passing an Array

 

 
Powered by phpBB® Forum Software