Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 9th, 2009, 01:59 PM
Friend of Wrox
Points: 489, Level: 7
Points: 489, Level: 7 Points: 489, Level: 7 Points: 489, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: Berkshire, United Kingdom.
Posts: 104
Thanks: 9
Thanked 1 Time in 1 Post
Default Looped Array compare

Chaps,

The issue i am having is with an array compare..

Until now my vacant grasp of splits and basic arrays has been enough but comparing two variable length arrays against each other has got me a tad stumpt..

'Firstly we have a results string:
ResString="100/1,101/2,104/5,109/3"

'Second String is a count of how many times the values in previous ResStrings have been used
UsedString="100/1#5,101/2#1,"

What i am attempting badley is to compare the ResString value against the UsedString value.
If the values match replace the UsedString record with an updated count value or if no compare was found to create a new UsedString value.

I can see part of the solution but the loop within loop is getting me ..

Split the first string
Code:
SplResString=Split(ResString,",")
Create the first loop
Code:
For x = 0 to ubound(SplResString)
Then i presume i can start the next array within the first (now probably going wrong)

Code:
SplUsedString=Split(UsedString,",")
For y = 0 to ubound(SplUsedString)
Then Add the second split
Code:
ReSplUsedString=Split(SplUsedString(y),"#")
and compare the two values (Sure way off here)
Code:
If SplResString(x) = ReSplUsedString(0) then
'Add to rate
newrate=Int(ReSplUsedString(1)) + 1
SplResString(x)=Replace(SplResString(x),ReSplUsedString(0)&#&ReSplUsedString(1),ReSplUsedString(0)&#&newrate)
If you can see where i am going any direction toward my rambling code would be great.

Cheers

Aspless
Reply With Quote
  #2 (permalink)  
Old April 10th, 2009, 12:58 AM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Can you, instead of the code, just tell us what the expected RESULTS are, given the inputs that you specified?

As I read you, you want to go from:
Code:
ResString="100/1,101/2,104/5,109/3"
 UsedString="100/1#5,101/2#1,"
to a new UsedString that will look like:
Code:
UsedString="100/1#6,101/2#2,104/5#1,109/3#1"
Is that even close to correct?

Dare I ask what prompted you to use this ultra-weird string-based notation, instead of just using a simple database?

Oh, and does it really matter what the order of the values in the new UsedString results are? That is, if it just so happened that we could more easily get
Code:
UsedString="109/3#1,100/1#6,104/5#1,101/2#2"
would you care?
Reply With Quote
  #3 (permalink)  
Old April 10th, 2009, 04:41 AM
Friend of Wrox
Points: 489, Level: 7
Points: 489, Level: 7 Points: 489, Level: 7 Points: 489, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: Berkshire, United Kingdom.
Posts: 104
Thanks: 9
Thanked 1 Time in 1 Post
Default Thanks for the reply

The original string "ResString" is a set of results from a simple survey.

The first element is associated with the question ID and the second is the rate (between 1 - 5) EG '101/5'

The survey could be taken by multiple people and there fore several results strings as above.

What i am trying to do is count the number of times a specific question and rate has been selected so that i can add to the main survey results record set.

Example results page below

Question Rate 1 Rate 2 Rate 3 Rate4 Rate5
Can aspless code? 10 times 7 Times 3 Times 0 Times 0 Times

The idea was to create a questions used string eg '101/5#12' which could be referenced quicker than checking each results string to identify the same counts.

Any thoughts to a cleaner solution would be great .. the end result - no pun intended is to produce a single survey record set which will include No of times a rate has been selected ..

For reference the question id’s do go in numerical order .. my example was inaccurate. Sorry!

Cheers


Aspless
Reply With Quote
  #4 (permalink)  
Old April 10th, 2009, 05:23 AM
Friend of Wrox
Points: 489, Level: 7
Points: 489, Level: 7 Points: 489, Level: 7 Points: 489, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: Berkshire, United Kingdom.
Posts: 104
Thanks: 9
Thanked 1 Time in 1 Post
Default SQL Database size against single rcordset query

One way to remove the need to have lot's of long strings would be to use further recordsets eg

Survey ID | Question ID | Rate 1 | Rate2 | Rate3 | Rate 4 | Rate5

The only reason i did not consider this option is the amount of database size used as a result.

How ever over what could be a very long question used string this is the better option..

Cheers

Aspless
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Page breaks in looped results table aspless Classic ASP Basics 4 January 23rd, 2009 05:05 PM
Pulling Looped XML Data Into ASP.NET Page kwilliams ASP.NET 2.0 Professional 2 January 22nd, 2008 11:34 AM
compare these date fields and compare and get the susanring Oracle 1 July 24th, 2006 04:58 PM
compare array with coma seperated table fileld vinodkalpaka BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 April 23rd, 2005 10:41 AM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM



All times are GMT -4. The time now is 09:39 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.