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

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 22nd, 2007, 12:04 AM
alexk13's Avatar
alexk13 alexk13 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Sydney, Australia
Posts: 213 alexk13 User rank is Second Lieutenant (5000 - 10000 Reputation Level)alexk13 User rank is Second Lieutenant (5000 - 10000 Reputation Level)alexk13 User rank is Second Lieutenant (5000 - 10000 Reputation Level)alexk13 User rank is Second Lieutenant (5000 - 10000 Reputation Level)alexk13 User rank is Second Lieutenant (5000 - 10000 Reputation Level)alexk13 User rank is Second Lieutenant (5000 - 10000 Reputation Level)alexk13 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 22 h 57 m 7 sec
Reputation Power: 89
2 dimensional array from a delimited string

Hi guys

I need to create a 2 dimensional array from a string with 2 kinds of delimiters

sample string:
Code:
1=1|2=2|3=3|4=4

in this case, the delimiteers are = and |
so my array would look something like this:
Code:
-------------
|  1  |  1  |
-------------
|  2  |  2  |
-------------
|  3  |  3  |
-------------
|  4  |  4  |
-------------


I have trid the following code, but ofcourse it failed me:
ASP Code:
Original - ASP Code
  1. str = "1=1|2=2|3=3|4=4"
  2. arr = split(str, "|")
  3. arr2 = split(arr, "=")
  4. Response.Write isArray(arr) & "<br />"
  5. Response.Write isArray(arr2) & "<br />"

If got the following error:
Code:
Microsoft VBScript runtime  error '800a000d'

Type mismatch: 'arr'

/asp/2darray.asp, line 4 

Is the a built-in ASP function to achieve what I am after, or is this something that I will need to create a special finction in my cocde to achieve?

Any help is appreciated.
__________________
Alex - Lucky Number 13

Did I do something that helped you? - please click the scales and help my rep

Last edited by alexk13 : October 22nd, 2007 at 01:09 AM.

Reply With Quote
  #2  
Old October 22nd, 2007, 01:11 AM
alexk13's Avatar
alexk13 alexk13 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Sydney, Australia
Posts: 213 alexk13 User rank is Second Lieutenant (5000 - 10000 Reputation Level)alexk13 User rank is Second Lieutenant (5000 - 10000 Reputation Level)alexk13 User rank is Second Lieutenant (5000 - 10000 Reputation Level)alexk13 User rank is Second Lieutenant (5000 - 10000 Reputation Level)alexk13 User rank is Second Lieutenant (5000 - 10000 Reputation Level)alexk13 User rank is Second Lieutenant (5000 - 10000 Reputation Level)alexk13 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 22 h 57 m 7 sec
Reputation Power: 89
I Found a solution - might not be the best solution but it does work

Just in case anyone else has a similar problem, here is my solution:

ASP Code:
Original - ASP Code
  1. <%
  2. ReDim myArr(1,1)
  3. str = "1=1|2=2|3=3|4=4|5=5|6=6"
  4. arr = split(str, "|")
  5. Response.Write isArray(arr) & "[" & uBound(arr) & "]<br />"
  6. For i = 0 to ubound(arr)
  7.     Response.Write arr(i)
  8.     arr2 = split(arr(i), "=")
  9.     Response.Write isArray(arr2) & "[" & arr2(0) & " | " & arr2(1) & "]<br />"
  10.     Redim Preserve myArr(1,i)
  11.     myArr(0,i) = arr2(0)
  12.     myArr(1,i) = arr2(1)
  13. Next
  14. Response.Write isArray(myArr) & "<br />"
  15. For i = 0 To uBound(arr)
  16.     Response.Write myArr(0,i) & "+" & myArr(1,i) & "<br />"
  17. Next
  18. %>

Reply With Quote
  #3  
Old October 22nd, 2007, 05:14 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 6 h 32 m 56 sec
Reputation Power: 182
Thanks for posting the update
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > 2 dimendional array from a delimited string


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





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek