Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Array Looping Problem

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,57625
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> Array Looping Problem
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Array Looping Problem - 3/6/2008 12:39:30 PM   
  nyonomay

 

Posts: 1
Score: 0
Joined: 3/6/2008
Status: offline
I am looping while both arrays are les than or equal to their ubound limits.
I want to do a strComp and increment the i or j counters as below, depending on the outcome of the string.
 
The problem is, when I run the program and feed it two arrays, the page either hangs and does nothing or I get an out of bounds error on i or j.
I need this function to work when the arrays that are being passed to it are of different lengths.

ANY help woul dbe wonderful, thanks in advance :)
 
----code---
function localTextMetric(tsortedTargetArray, sortedQueryArray)

do while i <= ubound(sortedTargetArray) or j <= ubound(sortedQueryArray)
 
                        if i<= ubound(sortedTargetArray) or j<= ubound(sortedQueryArray)then
                       
                        alpha = StrComp(sortedTargetArray(i), sortedQueryArray(j))
           
                                    if alpha = -1 then
                                    i = i + 1                       
                                    elseif alpha = 1 then
                                                j = j + 1
                                    elseif alpha = 0 then
                                                i = i + 1
                                                j = j + 1
                                                intersection = intersection + 1
                            end if          
                        end if  
            loop

response.write(i)
response.write(j)
response.write(intersection)

end function
 
 
Post #: 1
 
 RE: Array Looping Problem - 3/7/2008 4:39:54 AM   
  webber123456

 

Posts: 32
Score: 0
Joined: 9/20/2007
Status: offline
get the lower value first then set the loop to use that number.  don't try to do concurrently

(in reply to nyonomay)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> Array Looping Problem Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts