ARRAY/ Function Question

1. Eric Kowalewski Guest

## ARRAY/ Function Question

When I do this:<BR><BR>Function ray()<BR> Dim temp(4)<BR> temp(0)="E"<BR> temp(1)="R"<BR> temp(2)="I"<BR> temp(3)="C"<BR> <BR> for i = 0 to 3<BR> ray(i)=temp(i)<BR> next <BR>End Function<BR><BR>response.write ray<BR>%&#062;<BR><BR>I get this:<BR><BR>Microsoft VBScript runtime error &#039;800a000d&#039; <BR><BR>Type mismatch: &#039;ray&#039; <BR><BR>/test2.asp, line 11 <BR><BR><BR>When I do this:<BR><BR>&#060;%<BR><BR>Function ray()<BR> Dim temp(4)<BR> temp(0)="E"<BR> temp(1)="R"<BR> temp(2)="I"<BR> temp(3)="C"<BR> <BR> for i = 0 to 3<BR> ray(i)=temp(i)<BR> next <BR>End Function<BR><BR>response.write ray(0)<BR>%&#062;<BR><BR>I get this:<BR><BR>Microsoft VBScript runtime error &#039;800a01c2&#039; <BR><BR>Wrong number of arguments or invalid property assignment: &#039;ray&#039; <BR><BR>/test2.asp, line 15 <BR><BR><BR>What am I doing wrong here?<BR><BR> Thanks<BR> Eric

2. Senior Member
Join Date
Dec 1969
Posts
820

## RE: ARRAY/ Function Question

I think your problem is that the name of the function and the arrray are the same. Try giving the function a different name.

3. Eric Kowalewski Guest

## RE: ARRAY/ Function Question

It&#039;s a function. How then would I return it?

4. Steve Cimino Guest

## RE: ARRAY/ Function Question

Ray is the name of your function, and it&#039;s not yet an array. To return the array, you need to do:<BR><BR>ray = temp<BR><BR>Don&#039;t use subscripts at this point.

5. Eric Kowalewski Guest

## RE: ARRAY/ Function Question

Then why is it the when I do this?<BR><BR>&#060;%<BR>Function ray()<BR> Dim temp(4)<BR> temp(0)="E"<BR> temp(1)="R"<BR> temp(2)="I"<BR> temp(3)="C"<BR> <BR> ray=temp<BR>End Function<BR><BR>response.write ray<BR>%&#062;<BR><BR>I get this:<BR><BR>Response object error &#039;ASP 0106 : 80020005&#039; <BR><BR>Type Mismatch <BR><BR>? <BR><BR>An unhandled data type was encountered. <BR>

6. Senior Member
Join Date
Dec 1969
Posts
1,156

## RE: ARRAY/ Function Question

This is because you are trying to write an array, when you really want to write the CONTENTS of the array.<BR><BR>So <BR><BR> Response.Write ray()(3) <BR><BR>would give &#039;C&#039;.<BR><BR>Alternatively if you wanted to write the entire contents of the array, use the Join command. <BR><BR>So <BR><BR> Response.Write Join(ray(),"")<BR><BR>would give &#039;ERIC&#039;<BR><BR>Hope this helps<BR><BR>James

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•