ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 20th, 2004, 12:37 AM
debsaurus debsaurus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 4 debsaurus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Post Can VBScript Function procedure return an array?

Hi all,

i'm pretty new to VBScript. Having some doubts here.
Can a VBScript Function procedure return an array?

For example:

Function myfunction()
Dim myArray(1)
myArray(0) = "1"
myArray(1) = "2"

myfunction = myArray
End Function

Please advise. Thanks.

Reply With Quote
  #2  
Old May 20th, 2004, 02:50 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Posts: 2,056 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 44 m 22 sec
Reputation Power: 0
Yes - by the time you get this response you probably could have tried it for yourself.

Reply With Quote
  #3  
Old May 20th, 2004, 02:53 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Posts: 2,056 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 44 m 22 sec
Reputation Power: 0
Just tried it myself:
Code:
Function myfunction()
	Dim myArray(1)
	myArray(0) = "1"
	myArray(1) = "2"
	
	myfunction = myArray
End Function

response.write(typename(myfunction()))

Reply With Quote
  #4  
Old December 7th, 2004, 11:16 AM
umma umma is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 1 umma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
How do you access the elements in array returned by a function?

How do you access the elements in array returned by a function?

so when I use response.write (typename(myfunction(0))) it works and "variant" prints out

But when I try and reference the array via the function name:

myfunction(0) - zero being the ordinal number

I get the error:
Error Type:
Response object, ASP 0106 (0x80020005)
An unhandled data type was encountered

So what do you suggest?

Reply With Quote
  #5  
Old December 7th, 2004, 03:21 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
You would probably be best assigning the return value to a variable and printing that.

Dim newarray = myfunction()
reponse.write(newarray(0))


keep in mind that calling myfunction(0) is calling myfunction() with an integer argument.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Can VBScript Function procedure return an array?


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap