Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 30th, 2014, 06:57 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default transform delimited string into name value pairs

Hello all. The dictionary object can be used to transform a string into name value pairs however this is only going to work on a two dimensional structure. What option is there to do this with a string that is more than two dimensions?

Here is how I am using it currently:

Code:
'my example string is |#| delimited
assessStr = "aid=|#|objCatID=1|#|pid=18296|#|status=5|#|cid=12109|#|theDate=20140929145929"
set assess = Server.CreateObject("Scripting.Dictionary")
myArray = split(assessStr, newDelimiter1)
dim key,val,rec
for i = 0 to uBound(myArray)
    key = mid(myArray(i),1, instr(myArray(i), "=")-1 )
    val = replace(myArray(i), (key&"="), "")
    assess.add key,val
next
set myArray = nothing
'now can use these as name value pairs like so
response.write assess("aid") & "<BR>" & assess("objCatID") & "<BR>" & assess("pid") & "<BR>" & assess("status") & "<BR>" & response.write assess("cid") & "<BR>" & response.write assess("theDate") & "<BR>"
Also second question. If I have a string that has two delimiters (|#| and ~#~ ) such as:

objStr = "objID=1|#|status=1|#|or=A|#|mr=A|#|oc=someOwnComm ent|#|mc=someManagerComment~#~objID=2|#|status=1|# |or=D|#|mr=D|#|oc=someOwnComment|#|mc=someManagerC omment~#~objID=3|#|status=1|#|or=C|#|mr=C|#|oc=som eOwnComment|#|mc=someManagerComment"

To make all of these name value pairs available as per above, would using two nested dictionary objects the most efficient method
__________________
Wind is your friend
Matt




Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual basic: Display pictures in matching pairs game Whitesword77 Visual Basic 2008 Essentials 0 June 1st, 2009 08:27 PM
Adding value pairs to a combo box tebert2458 C# 2 February 25th, 2009 06:10 AM
Transform String, Removing Characters. v01 XSLT 3 November 21st, 2008 01:58 PM
How to split a long string with tab delimited Andraw SQL Server 2005 27 July 17th, 2008 05:38 PM
Parsing Large Delimited Text String Coop64 SQL Language 1 February 16th, 2004 03:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.