Hi,

I need to pass an array to a function, change it a little and return it to
the main code. When i try it the webpage is displayed up until the function
call. Nothing after that is displayed. When debugging in VS 6 it says: "An
exception of type 'Error in Microsoft VBScript: Incompatible types' was not
handled".

'Main code
'-----------------------------------------------------
dim list(8)
dim newlist(8)

Randomize
For counter = 0 To 4
list(counter) = Int(Rnd * 21)
Response.Write list(counter) & ", "
Next

Response.Write "<br>"
newlist = listFunction(list)

For counter = 0 To 4
Response.Write newlist(counter) & ", "
Next


'function
'-----------------------------------------------------
Function listFunction(list)
dim tmplist(8)

Randomize
For k = 0 To 4
tmplist(k) = list(k)*2
Next

listFunction = tmplist
End Function


Also, when reloading the page i sometimes get the message 'A RPC (Remote
Procedure Call) was not executed' (the message is translated from swedish by
me). Does anyone know what i am doing wrong? Any help is welcome.

/H

Re: Passing arrays through functions by Ray

Ray
Mon Sep 15 07:56:15 CDT 2003

Try dimming newlist like so:

'Main code
'-----------------------------------------------------
dim list(8)
dim newlist

Randomize
...

Ray at work


"Henry" <henrik.pierrou@swipnet.se> wrote in message
news:Mii9b.980$d1.405@nntpserver.swip.net...
> Hi,
>
> I need to pass an array to a function, change it a little and return it to
> the main code. When i try it the webpage is displayed up until the
function
> call. Nothing after that is displayed. When debugging in VS 6 it says: "An
> exception of type 'Error in Microsoft VBScript: Incompatible types' was
not
> handled".
>
> 'Main code
> '-----------------------------------------------------
> dim list(8)
> dim newlist(8)
>
> Randomize
> For counter = 0 To 4
> list(counter) = Int(Rnd * 21)
> Respons



Re: Passing arrays through functions by Henry

Henry
Mon Sep 15 09:27:24 CDT 2003

Thanks Ray. That worked fine. Would you care to explain why that works and
not my initial code?

/Henrik

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> skrev i meddelandet
news:OPNaBj4eDHA.2352@TK2MSFTNGP10.phx.gbl...
> Try dimming newlist like so:
>
> 'Main code
> '-----------------------------------------------------
> dim list(8)
> dim newlist
>
> Randomize
> ...
>
> Ray at work
>
>
> "Henry" <henrik.pierrou@swipnet.se> wrote in message
> news:Mii9b.980$d1.405@nntpserver.swip.net...
> > Hi,
> >
> > I need to pass an array to a function, change it a little and return it
to
> > the main code. When i try it the webpage is displayed up until the
> function
> > call. Nothing after that is displayed. When debugging in VS 6 it says:
"An
> > exception of type 'Error in Microsoft VBScript: Incompatible types' was
> not
> > handled".
> >
> > 'Main code
> > '-----------------------------------------------------
> > dim list(8)
> > dim newlist(8)
> >
> > Randomize
> > For counter = 0 To 4
> > list(counter) = Int(Rnd * 21)
> > Respons
>
>



Re: Passing arrays through functions by Ray

Ray
Mon Sep 15 09:44:16 CDT 2003

I think it's just one of the rules that once you declare a variable as an
array, you cannot go and assign the whole array as something else, even if
it is an array. By dimming it without the (), it is just a variant, and you
can convert that variant into an array by "copying" the existing array.

Ray at work

"Henry" <henrik.pierrou@swipnet.se> wrote in message
news:07j9b.982$d1.448@nntpserver.swip.net...
> Thanks Ray. That worked fine. Would you care to explain why that works and
> not my initial code?
>
> /Henrik
>
> "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> skrev i
meddelandet
> news:OPNaBj4eDHA.2352@TK2MSFTNGP10.phx.gbl...
> > Try dimming newlist like so:
> >
> > 'Main code
> > '-----------------------------------------------------
> > dim list(8)
> > dim newlist
> >
> > Randomize
> > ...
> >
> > Ray at work
> >
> >
> > "Henry" <henrik.pierrou@swipnet.se> wrote in message
> > news:Mii9b.980$d1.405@nntpserver.swip.net...
> > > Hi,
> > >
> > > I need to pass an array to a function, change it a little and return
it
> to
> > > the main code. When i try it the webpage is displayed up until the
> > function
> > > call. Nothing after that is displayed. When debugging in VS 6 it says:
> "An
> > > exception of type 'Error in Microsoft VBScript: Incompatible types'
was
> > not
> > > handled".
> > >
> > > 'Main code
> > > '-----------------------------------------------------
> > > dim list(8)
> > > dim newlist(8)
> > >
> > > Randomize
> > > For counter = 0 To 4
> > > list(counter) = Int(Rnd * 21)
> > > Respons
> >
> >
>
>