473,322 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

returning arrays from COM to JScript

2
On Apr 28 2001, 6:06 am, "Michael Harris" <mik...@mvps.org> wrote:

> "...So there is no way to transparentlyreturnanarrayinJScript?..."

> To be "JScript-friendly", you have toreturn*everything" via a >functionreturnvalue. And as I
> said before,JScriptcan handle a SAFEARRAY by converting it with VBArray() >since aJScriptarray
> isn't really anarraybut rather a special (IDispatch[Ex] based)JScriptobject with >numeric
> properties.

JScript takes array[0] as array.0
Sep 25 '07 #1
2 1571
weaknessforcats
9,208 Expert Mod 8TB
What's the question?
Sep 25 '07 #2
dspc
2
What's the question?
http://groups.google.com/group/microsoft.public.scripting.jscript/browse_thread/thread/0e10ec0571c9ca48/2d160e9d46d49c3e


JScript takes array[0][1] as array.0.1


Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. STDMETHODIMP CUfmArray::XLocalClass::GetDispID( 
  4.       BSTR bstrName, DWORD grfdex, DISPID *pid)
  5. {
  6.     METHOD_PROLOGUE(CUfmArray, LocalClass)
  7.  
  8.     CString strValue;
  9.     if(pThis->m_psaAry.Lookup(CString(bstrName),strValue))
  10.     {
  11.         *pid =pThis->m_pidAry->GetCount()+0x1000;
  12.         pThis->m_pidAry->AddTail(strValue);
  13.  
  14.         return S_OK;
  15.     }
  16.     return pThis->m_JuggleAry->GetDispID( bstrName,  grfdex,  pid);
  17. }
  18.  
  19. STDMETHODIMP CUfmArray::XLocalClass::InvokeEx( 
  20.      DISPID id, LCID lcid, WORD wFlags,
  21.      DISPPARAMS *pdp,  VARIANT *pvarRes, EXCEPINFO *pei,
  22.      IServiceProvider *pspCaller)
  23. {
  24.     METHOD_PROLOGUE(CUfmArray, LocalClass)
  25.  
  26.     CString strValue;
  27.     if(strValue = pThis->m_pidAry->GetAt(pThis->m_pidAry->FindIndex(id-0x1000)))
  28.     {
  29.             // Validate that they passed in a valid variant for results
  30.             // and have no parameters assigned to the "Get"
  31.             if( pvarRes != NULL &&
  32.                 (pdp == NULL || pdp->cArgs == 0) )
  33.             {
  34.                 // Do the "Get" with the specified ID
  35.                 VariantClear(pvarRes);
  36.                 pvarRes->vt =VT_BSTR;
  37.                 pvarRes->bstrVal = strValue.AllocSysString();
  38.             }
  39.             else
  40.             {
  41.                 // They passed in bogus stuff
  42.                 return E_INVALIDARG;
  43.             }
  44.         return S_OK;
  45.     }
  46.  
  47.  
  48.     HRESULT hr = pThis->m_JuggleAry->InvokeEx(  id,  lcid,  wFlags,
  49.       pdp,   pvarRes,  pei,
  50.       pspCaller);
  51.  
  52.     if(hr ==E_POINTER)
  53.     {
  54.         IUfmArray* pSry =(IUfmArray*)pThis->GetInterface(&IID_IUfmArray);
  55.  
  56.  
  57.                 UINT nErrArg = 0;
  58.  
  59.                 hr =pSry->Invoke(  id, IID_NULL, lcid,  wFlags,
  60.       pdp,   pvarRes,  pei,
  61.       &nErrArg);
  62.     }
  63.     return hr;
  64. }
  65.  
  66.  
Sep 26 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: jeff | last post by:
I have a php file that contains a couple of arrays used for state/country pull-down lists. I have two global arrays and an accessor method for each. I have some simple logging methods, so I know a...
5
by: Gent | last post by:
I have two questions which are very similar: Is it possible to return an object in C++. Below is part of my code for reference however I am more concerned about the concept. It seems like the...
8
by: Derek Basch | last post by:
Is there any way to associate name/value pairs during an array initialization? Like so: sType = "funFilter" filterTypeInfo = ; filterTypeInfo = new Array("type" : sType); I can do it using...
7
by: dotnettester | last post by:
Hi, I am maintaining some code and I see in some functions.. Function myFunction set someobj = Server.CreateObject("MYOBJ") ..... .... set myFunction = "somedataToReturn"
3
by: Faustino Dina | last post by:
Hi, The following code is from an article published in Informit.com at http://www.informit.com/guides/content.asp?g=dotnet&seqNum=142. The problem is the author says it is not a good idea to...
26
by: cdg | last post by:
Could anyone correct any mistakes in this example program. I am just trying to return an array back to "main" to be printed out. And I am not sure how a "pointer to an array" is returned to the...
17
by: I.M. !Knuth | last post by:
Hi. I'm more-or-less a C newbie. I thought I had pointers under control until I started goofing around with this: ...
3
by: sjsean | last post by:
All thanks in advance for reading my post. I am new to using js and more accustomed to vbscript. I had written code which created a shopping cart into an array using vbscript and then...
8
by: jodleren | last post by:
Hi! I have a function, a part of my code which I can use as a function. It will return 2 arrays, and I am wondering what way to do so. Both arrays hold strings, there are no special keys. 1)...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.