Array Looping Problem

Author Message
nyonomay

  • Total Posts : 1
  • Scores: 0
  • Reward points : 0
  • Joined: 3/6/2008
  • Status: offline
Array Looping Problem Thursday, March 06, 2008 1:39 PM (permalink)
0
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
 
#1
    webber123456

    • Total Posts : 58
    • Scores: 0
    • Reward points : 0
    • Joined: 9/20/2007
    • Status: offline
    RE: Array Looping Problem Friday, March 07, 2008 5:39 AM (permalink)
    0
    get the lower value first then set the loop to use that number.  don't try to do concurrently
     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • 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
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9