PDA

View Full Version : New array types and asp



Nick Wright
15-Nov-2005, 06:57 PM
I would like to return an array type to an asp page from my web object:

Function whatever returns integer[]
etc
End_Function

In the asp page I would like to call the function but i'm not sure how to
fill the asp array

e.g.

<%
dim myar(10)

???????? = omyobject.call("get_whatever")
%>
then address each element when needed

<% If myar(1) = 1 then %>

Is this possible? The only examples I have seen show the asp array being
filled one element at a time

e.g.
<%
myar(0)=1
myar(1)=2
%>

TIA

Nick

Harper Carr
22-Nov-2005, 12:34 PM
Nick Wright wrote:
> I would like to return an array type to an asp page from my web object:
>
> Function whatever returns integer[]
> etc
> End_Function
>
> In the asp page I would like to call the function but i'm not sure how to
> fill the asp array
>
> e.g.
>
> <%
> dim myar(10)
>
> ???????? = omyobject.call("get_whatever")
> %>
> then address each element when needed
>
> <% If myar(1) = 1 then %>
>
> Is this possible? The only examples I have seen show the asp array being
> filled one element at a time
>
> e.g.
> <%
> myar(0)=1
> myar(1)=2
> %>
>
> TIA
>
> Nick
>
>
>
>
It hope it is possible. I have a site that does this using VB; all the
DB access is done in a COM object written in VB and the individual .asp
pages just make calls to the COM object. The array is passed byRef to
the COM object and is updated there, then the .asp page just loops
through the array.

But I cannot get it to work using VDF. I've tried 11.0 and 11.1.

I've tried passing the array byRef to the VDF web object.
I've tried having the web object function return an array.

It simply won't work.

Harper Carr

Marco
22-Nov-2005, 09:55 PM
Hi Nick,

What I've done in the past, is returning VB Code in a string back to the
asp page. The code contained the declaration of an array and the setting
of the values.

Then in ASP I execute the string...

Works like a charm.

Sample?

In Wo:
Function AllData Returns String
String sData
Append sData "Dim oArray(5,2):Erase oArray:"
Append sData 'oArray(1,1)="val1":oArray(1,2)="val1":'
Append sData 'oArray(2,1)="val1":oArray(2,2)="val1":'
Append sData 'oArray(3,1)="val1":oArray(3,2)="val1":'
Append sData 'oArray(4,1)="val1":oArray(4,2)="val1":'
Append sData 'oArray(5,1)="val1":oArray(5,2)="val1":'
Function_return sData
End_Function

In ASP:

sVal = Wbo.call("get_AllData")
Execute sVal

iRows = (UBound(oArray,1))

For iRow = 0 to iRows
Response.Write(oArray(iRow,1))
Response.Write(oArray(iRow,2))
Next

Or something like that (working from 3 year old memories now).

Cheers,
Marco








Nick Wright wrote:
> I would like to return an array type to an asp page from my web object:
>
> Function whatever returns integer[]
> etc
> End_Function
>
> In the asp page I would like to call the function but i'm not sure how to
> fill the asp array
>
> e.g.
>
> <%
> dim myar(10)
>
> ???????? = omyobject.call("get_whatever")
> %>
> then address each element when needed
>
> <% If myar(1) = 1 then %>
>
> Is this possible? The only examples I have seen show the asp array being
> filled one element at a time
>
> e.g.
> <%
> myar(0)=1
> myar(1)=2
> %>
>
> TIA
>
> Nick
>
>
>
>

Harper Carr
23-Nov-2005, 10:53 AM
Marco Kuipers wrote:
> Hi Nick,
>
> What I've done in the past, is returning VB Code in a string back to the
> asp page. The code contained the declaration of an array and the setting
> of the values.
>
> Then in ASP I execute the string...
>
> Works like a charm.
>
> Sample?
>
> In Wo:
> Function AllData Returns String
> String sData
> Append sData "Dim oArray(5,2):Erase oArray:"
> Append sData 'oArray(1,1)="val1":oArray(1,2)="val1":'
> Append sData 'oArray(2,1)="val1":oArray(2,2)="val1":'
> Append sData 'oArray(3,1)="val1":oArray(3,2)="val1":'
> Append sData 'oArray(4,1)="val1":oArray(4,2)="val1":'
> Append sData 'oArray(5,1)="val1":oArray(5,2)="val1":'
> Function_return sData
> End_Function
>
> In ASP:
>
> sVal = Wbo.call("get_AllData")
> Execute sVal
>
> iRows = (UBound(oArray,1))
>
> For iRow = 0 to iRows
> Response.Write(oArray(iRow,1))
> Response.Write(oArray(iRow,2))
> Next
>
> Or something like that (working from 3 year old memories now).
>
> Cheers,
> Marco
>

Hmmmmm.......

Maybe its because the seasons are reversed down there, but a hack like
that I would not consider "works like a charm." Before VDF11 I can
understand why a hack like that was needed, because VDF didn't have an
array type. But, since VDF now supports a native array type, it SHOULD
be possible to do this:

In WO:
function test returns string[]
string[] myArray

move "How" to foo[0]
move "now" to foo[1]
move "brown" to foo[2]
move "cow" to foo[3]
move "!" to foo[4]

function_return foo
end_function

In .asp page:

Dim myArray()

myArray = WO.call("get_test")

for i = 0 to uBound(myArray) - 1
blah...blah...blah

then process the array how ever you want on the page.

Has anyone done it?

Harper

Marco
23-Nov-2005, 07:54 PM
Sorry Harper,

I did this in the WebApp 3 days...
Then every call from the ASP to the W(B)O was soooooo sloooow.

I had to pass some 1000odd values to the asp, to build a XLS within the
ASP and stream the result to the browser.

As it was soo slow, I experimented with this way and it worked...

I do think your way is very elegant, but I wonder how long we have to
wait for this to work. I would definately not assume it already does.

Cheers,
Marco


Harper Carr wrote:
> Marco Kuipers wrote:
>
>> Hi Nick,
>>
>> What I've done in the past, is returning VB Code in a string back to
>> the asp page. The code contained the declaration of an array and the
>> setting of the values.
>>
>> Then in ASP I execute the string...
>>
>> Works like a charm.
>>
>> Sample?
>>
>> In Wo:
>> Function AllData Returns String
>> String sData
>> Append sData "Dim oArray(5,2):Erase oArray:"
>> Append sData 'oArray(1,1)="val1":oArray(1,2)="val1":'
>> Append sData 'oArray(2,1)="val1":oArray(2,2)="val1":'
>> Append sData 'oArray(3,1)="val1":oArray(3,2)="val1":'
>> Append sData 'oArray(4,1)="val1":oArray(4,2)="val1":'
>> Append sData 'oArray(5,1)="val1":oArray(5,2)="val1":'
>> Function_return sData
>> End_Function
>>
>> In ASP:
>>
>> sVal = Wbo.call("get_AllData")
>> Execute sVal
>>
>> iRows = (UBound(oArray,1))
>>
>> For iRow = 0 to iRows
>> Response.Write(oArray(iRow,1))
>> Response.Write(oArray(iRow,2))
>> Next
>>
>> Or something like that (working from 3 year old memories now).
>>
>> Cheers,
>> Marco
>>
>
> Hmmmmm.......
>
> Maybe its because the seasons are reversed down there, but a hack like
> that I would not consider "works like a charm." Before VDF11 I can
> understand why a hack like that was needed, because VDF didn't have an
> array type. But, since VDF now supports a native array type, it SHOULD
> be possible to do this:
>
> In WO:
> function test returns string[]
> string[] myArray
>
> move "How" to foo[0]
> move "now" to foo[1]
> move "brown" to foo[2]
> move "cow" to foo[3]
> move "!" to foo[4]
>
> function_return foo
> end_function
>
> In .asp page:
>
> Dim myArray()
>
> myArray = WO.call("get_test")
>
> for i = 0 to uBound(myArray) - 1
> blah...blah...blah
>
> then process the array how ever you want on the page.
>
> Has anyone done it?
>
> Harper