|
-
Returning data from VC++ ASP component
Hello,
I have to write an ASP Component in VC++ who returns multiple variables.
What is the easiest way to return for example 3 variables from the
VC++ component to an ASP page written in VBScript ?
- Can I do it using OUT parameters in the methods ; If so, how can I do it
in my C++ method using OLE
Automation ? And how can I code it in my ASP page using VBScript ?
- If not, what is the easiest way to return these parameters ? Where can
I find an easy sample of it ?
Any help would be much appreciated.
Thank you very much
Zohar Nissare-Houssen
TravelNet Technologies
-
Re: Returning data from VC++ ASP component
Hello Zohar. I have very little experience with creating COM components via
VC++. I've only done this once just to see if I could! :-) You can read
about my attempts at: http://www.4guysfromrolla.com/webtech/052600-1.shtml
I'd also HIGHLY recommend that you join this ListServ: http://www.asplists.com/asplists/asp...components.asp
Ask your questions there and you'll get great responses from seasoned pros...
Happy Programming!
Scott Mitchell
mitchell@4guysfromrolla.com
http://www.4GuysFromRolla.com
http://www.ASPMessageBoard.com
http://www.ASPFAQs.com
* When you think ASP, think 4GuysFromRolla.com!
"Zohar Nissare-Houssen" <znissare@travelnet.ca> wrote:
>
>Hello,
>
>I have to write an ASP Component in VC++ who returns multiple variables.
>
>What is the easiest way to return for example 3 variables from the
>VC++ component to an ASP page written in VBScript ?
>
>- Can I do it using OUT parameters in the methods ; If so, how can I do
it
>in my C++ method using OLE
>Automation ? And how can I code it in my ASP page using VBScript ?
>
>- If not, what is the easiest way to return these parameters ? Where can
>I find an easy sample of it ?
>
>
>Any help would be much appreciated.
>
>Thank you very much
>
>Zohar Nissare-Houssen
>TravelNet Technologies
>
-
Re: Returning data from VC++ ASP component
Hello Scott,
Thank you very much for your help. The ListServ link you gave me will be
very useful...
But I have another question related this time to VBScript language coding
in ASP
still related to my problem :-)
I finally wrote a component method who returns an array of variant. Let's
say that this method is called
ReturnArray and takes two IN parameters, I coded the following in my ASP
page :
<%set MyObject=Server.CreateObject("ASPCOMPONENT.MYOBJECT")%>
...
Dim foo(3) [or Dim foo()]
foo = MyObject.ReturnArray(v1,v2)
This code causes a type mismatch error.
IsArray( MyObject.ReturnArray(v1,v2) ) returns TRUE
VarType( MyObject.ReturnArray(v1,v2) ) returns 8192 (vbArray constant)
So my return type is recognised as an array by VBScript but I can't pass
it directly into an array variable. I coded then a
VBScript procedure copying two arrays, element by element : Sub CopyArray(array_dest,array_origin,nbelements).
I use it like that
Dim foo(3)
CopyArray foo, MyObject.ReturnArray(v1,v2), 3
This code also causes a type mismatch error on array_origin
Then, I wrote another method in VC++ returning an element of an array. Let's
say this method is
ReturnArrayElem(Array,position)
In my ASP page this code works :
foo0 = MyObject.ReturnArrayElem( MyObject.ReturnArray(v1,v2) , 0 )
foo1 = MyObject.ReturnArrayElem( MyObject.ReturnArray(v1,v2) , 1 )
...
But the problem is that all the array is processed each time I need an element...
So, my question is : How can I stock the array resulting from a method call
in VBscript ? Is it possible ?
Any idea would be much appreciated.
Thank you
Zohar Nissare-Houssen
TravelNet Technologies
"Scott Mitchell" <mitchell@4guysfromrolla.com> wrote:
>
>Hello Zohar. I have very little experience with creating COM components
via
>VC++. I've only done this once just to see if I could! :-) You can read
>about my attempts at: http://www.4guysfromrolla.com/webtech/052600-1.shtml
>
>I'd also HIGHLY recommend that you join this ListServ: http://www.asplists.com/asplists/asp...components.asp
>
>Ask your questions there and you'll get great responses from seasoned pros...
>
>Happy Programming!
>
> Scott Mitchell
> mitchell@4guysfromrolla.com
> http://www.4GuysFromRolla.com
> http://www.ASPMessageBoard.com
> http://www.ASPFAQs.com
>
>* When you think ASP, think 4GuysFromRolla.com!
>
>"Zohar Nissare-Houssen" <znissare@travelnet.ca> wrote:
>>
>>Hello,
>>
>>I have to write an ASP Component in VC++ who returns multiple variables.
>>
>>What is the easiest way to return for example 3 variables from the
>>VC++ component to an ASP page written in VBScript ?
>>
>>- Can I do it using OUT parameters in the methods ; If so, how can I do
>it
>>in my C++ method using OLE
>>Automation ? And how can I code it in my ASP page using VBScript ?
>>
>>- If not, what is the easiest way to return these parameters ? Where can
>>I find an easy sample of it ?
>>
>>
>>Any help would be much appreciated.
>>
>>Thank you very much
>>
>>Zohar Nissare-Houssen
>>TravelNet Technologies
>>
>
-
Re: Returning data from VC++ ASP component
Have you tried:
Dim foo
foo = MyObject.ReturnArray(v1,v2)
???
"Zohar Nissare-Houssen" <znissare@travelnet.ca> wrote:
>
>Hello Scott,
>
>Thank you very much for your help. The ListServ link you gave me will be
>very useful...
>But I have another question related this time to VBScript language coding
>in ASP
>still related to my problem :-)
>
>I finally wrote a component method who returns an array of variant. Let's
>say that this method is called
>ReturnArray and takes two IN parameters, I coded the following in my ASP
>page :
>
><%set MyObject=Server.CreateObject("ASPCOMPONENT.MYOBJECT")%>
>...
>Dim foo(3) [or Dim foo()]
>foo = MyObject.ReturnArray(v1,v2)
>
>This code causes a type mismatch error.
>
>IsArray( MyObject.ReturnArray(v1,v2) ) returns TRUE
>VarType( MyObject.ReturnArray(v1,v2) ) returns 8192 (vbArray constant)
>
>So my return type is recognised as an array by VBScript but I can't pass
>it directly into an array variable. I coded then a
>VBScript procedure copying two arrays, element by element : Sub CopyArray(array_dest,array_origin,nbelements).
>I use it like that
>
>Dim foo(3)
>CopyArray foo, MyObject.ReturnArray(v1,v2), 3
>
>This code also causes a type mismatch error on array_origin
>
>Then, I wrote another method in VC++ returning an element of an array. Let's
>say this method is
>ReturnArrayElem(Array,position)
>
>In my ASP page this code works :
>
>foo0 = MyObject.ReturnArrayElem( MyObject.ReturnArray(v1,v2) , 0 )
>foo1 = MyObject.ReturnArrayElem( MyObject.ReturnArray(v1,v2) , 1 )
>...
>
>But the problem is that all the array is processed each time I need an element...
>
>So, my question is : How can I stock the array resulting from a method
call
>in VBscript ? Is it possible ?
>
>Any idea would be much appreciated.
>
>Thank you
>
>Zohar Nissare-Houssen
>TravelNet Technologies
>
>
>
>
>
>"Scott Mitchell" <mitchell@4guysfromrolla.com> wrote:
>>
>>Hello Zohar. I have very little experience with creating COM components
>via
>>VC++. I've only done this once just to see if I could! :-) You can read
>>about my attempts at: http://www.4guysfromrolla.com/webtech/052600-1.shtml
>>
>>I'd also HIGHLY recommend that you join this ListServ: http://www.asplists.com/asplists/asp...components.asp
>>
>>Ask your questions there and you'll get great responses from seasoned pros...
>>
>>Happy Programming!
>>
>> Scott Mitchell
>> mitchell@4guysfromrolla.com
>> http://www.4GuysFromRolla.com
>> http://www.ASPMessageBoard.com
>> http://www.ASPFAQs.com
>>
>>* When you think ASP, think 4GuysFromRolla.com!
>>
>>"Zohar Nissare-Houssen" <znissare@travelnet.ca> wrote:
>>>
>>>Hello,
>>>
>>>I have to write an ASP Component in VC++ who returns multiple variables.
>>>
>>>What is the easiest way to return for example 3 variables from the
>>>VC++ component to an ASP page written in VBScript ?
>>>
>>>- Can I do it using OUT parameters in the methods ; If so, how can I do
>>it
>>>in my C++ method using OLE
>>>Automation ? And how can I code it in my ASP page using VBScript ?
>>>
>>>- If not, what is the easiest way to return these parameters ? Where can
>>>I find an easy sample of it ?
>>>
>>>
>>>Any help would be much appreciated.
>>>
>>>Thank you very much
>>>
>>>Zohar Nissare-Houssen
>>>TravelNet Technologies
>>>
>>
>
-
Re: Returning data from VC++ ASP component
Hi Scott,
I finally solved my problem. It was not a VBScript problem. The problem was
on the Array type returned
by my component method.
From VBScript, the good hint that helped me was that :
VarType( MyObject.ReturnArray(v1,v2) ) returns 8192 (vbArray constant)
And, In fact, I learned that you can never get VarType of only 8192 - it
always has to be an array of
something (And as return result from COM objects, VBScript only supports
ARRAY of VARIANTS)
So, I should have get the following value for an array of nb=2 elements :
8204 = 1* (vbArray=8192) + (nb-1)*(vbVariant=12)
Another VBScript function is also very useful : TypeName(MyObject.ReturnArray(v1,v2))
to check
return array from COM VB/VC Component. It should always return string "Variant()"
for an
array of variant.
Zohar
"Scott Mitchell" <mitchell@4guysfromrolla.com> wrote:
>
>Have you tried:
>Dim foo
>foo = MyObject.ReturnArray(v1,v2)
>
>???
>
>"Zohar Nissare-Houssen" <znissare@travelnet.ca> wrote:
>>
>>Hello Scott,
>>
>>Thank you very much for your help. The ListServ link you gave me will be
>>very useful...
>>But I have another question related this time to VBScript language coding
>>in ASP
>>still related to my problem :-)
>>
>>I finally wrote a component method who returns an array of variant. Let's
>>say that this method is called
>>ReturnArray and takes two IN parameters, I coded the following in my ASP
>>page :
>>
>><%set MyObject=Server.CreateObject("ASPCOMPONENT.MYOBJECT")%>
>>...
>>Dim foo(3) [or Dim foo()]
>>foo = MyObject.ReturnArray(v1,v2)
>>
>>This code causes a type mismatch error.
>>
>>IsArray( MyObject.ReturnArray(v1,v2) ) returns TRUE
>>VarType( MyObject.ReturnArray(v1,v2) ) returns 8192 (vbArray constant)
>>
>>So my return type is recognised as an array by VBScript but I can't pass
>>it directly into an array variable. I coded then a
>>VBScript procedure copying two arrays, element by element : Sub CopyArray(array_dest,array_origin,nbelements).
>>I use it like that
>>
>>Dim foo(3)
>>CopyArray foo, MyObject.ReturnArray(v1,v2), 3
>>
>>This code also causes a type mismatch error on array_origin
>>
>>Then, I wrote another method in VC++ returning an element of an array.
Let's
>>say this method is
>>ReturnArrayElem(Array,position)
>>
>>In my ASP page this code works :
>>
>>foo0 = MyObject.ReturnArrayElem( MyObject.ReturnArray(v1,v2) , 0 )
>>foo1 = MyObject.ReturnArrayElem( MyObject.ReturnArray(v1,v2) , 1 )
>>...
>>
>>But the problem is that all the array is processed each time I need an
element...
>>
>>So, my question is : How can I stock the array resulting from a method
>call
>>in VBscript ? Is it possible ?
>>
>>Any idea would be much appreciated.
>>
>>Thank you
>>
>>Zohar Nissare-Houssen
>>TravelNet Technologies
>>
>>
>>
>>
>>
>>"Scott Mitchell" <mitchell@4guysfromrolla.com> wrote:
>>>
>>>Hello Zohar. I have very little experience with creating COM components
>>via
>>>VC++. I've only done this once just to see if I could! :-) You can
read
>>>about my attempts at: http://www.4guysfromrolla.com/webtech/052600-1.shtml
>>>
>>>I'd also HIGHLY recommend that you join this ListServ: http://www.asplists.com/asplists/asp...components.asp
>>>
>>>Ask your questions there and you'll get great responses from seasoned
pros...
>>>
>>>Happy Programming!
>>>
>>> Scott Mitchell
>>> mitchell@4guysfromrolla.com
>>> http://www.4GuysFromRolla.com
>>> http://www.ASPMessageBoard.com
>>> http://www.ASPFAQs.com
>>>
>>>* When you think ASP, think 4GuysFromRolla.com!
>>>
>>>"Zohar Nissare-Houssen" <znissare@travelnet.ca> wrote:
>>>>
>>>>Hello,
>>>>
>>>>I have to write an ASP Component in VC++ who returns multiple variables.
>>>>
>>>>What is the easiest way to return for example 3 variables from the
>>>>VC++ component to an ASP page written in VBScript ?
>>>>
>>>>- Can I do it using OUT parameters in the methods ; If so, how can I
do
>>>it
>>>>in my C++ method using OLE
>>>>Automation ? And how can I code it in my ASP page using VBScript ?
>>>>
>>>>- If not, what is the easiest way to return these parameters ? Where
can
>>>>I find an easy sample of it ?
>>>>
>>>>
>>>>Any help would be much appreciated.
>>>>
>>>>Thank you very much
>>>>
>>>>Zohar Nissare-Houssen
>>>>TravelNet Technologies
>>>>
>>>
>>
>
Similar Threads
-
Replies: 0
Last Post: 10-16-2002, 01:31 PM
-
By Paul Klanderud in forum ASP.NET
Replies: 0
Last Post: 02-04-2001, 04:24 PM
-
By Tracie in forum ASP.NET
Replies: 4
Last Post: 11-01-2000, 03:59 PM
-
By AnandaTirtha.NR in forum authorevents.mitchell
Replies: 1
Last Post: 10-17-2000, 09:17 AM
-
By C. Liacopoulos in forum authorevents.mitchell
Replies: 0
Last Post: 10-17-2000, 01:53 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks