Am I likely to cause an error?

Discussion in 'ASP General' started by Rob Meade, Jul 10, 2006.

  1. Rob Meade

    Rob Meade Guest

    Hi all,

    I have some code which compares values in a recordset to that in an array.

    If it finds a match it needs to remove the item from the array.

    My concern is that my method for removing the item from the array is by
    iterating through it, if it doesn't match then I place the value into a
    "temporary" array, after all comparisions are completed I then set the
    original array to equal the temporary array.

    Am I likely to generate an error if my internal looping of the same array
    changes the array size, whilst still iterating through it..

    eg..

    For x = 0 to ....

    if comparision is true then

    for y = 0 to ....

    if comparision is false then

    ' add value to temporary array here

    end if

    next

    array = temporary array

    end if

    Next

    My feeling is that this will go mammories up...

    Regards

    Rob
     
    Rob Meade, Jul 10, 2006
    #1
    1. Advertising

  2. Rob Meade

    CJM Guest

    "Rob Meade" <> wrote in message
    news:...

    >
    > Am I likely to generate an error


    Hopefully.. it's what development is all about...!

    > if my internal looping of the same array changes the array size, whilst
    > still iterating through it..
    >


    OIC. Yes definitely. At least I think so, give the little that you have told
    us.

    If you are intent on looping through your initial array, and you mean to
    selectively remove items from it, whilst continually updating it, then yes
    you will invoke an error... At some point your original array will shrink
    and your loop will try to query an item that no longers exists - when x = a
    value greater than the UBound of your modified array.

    >
    > My feeling is that this will go mammories up...
    >


    Same here.

    More importantly, I dont think your overall approach is right, but it's
    difficult to tell without a bit more context. What are actually trying to
    achieve?

    Regardless, I wouldnt recommend modify your initial array until you have
    completely looped through it.

    CJM
     
    CJM, Jul 10, 2006
    #2
    1. Advertising

  3. Rob Meade

    Rob Meade Guest

    "CJM" wrote ...

    > Same here.


    Cheers for the confirmation...

    > More importantly, I dont think your overall approach is right, but it's
    > difficult to tell without a bit more context. What are actually trying to
    > achieve?


    It's a rather long winded explanation so I'll not trouble you with it - as I
    think I'm about there now, but just needed to check this as I guessed a
    different approach would be needed..

    Thanks :eek:)

    Rob
     
    Rob Meade, Jul 10, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Julian McMaster

    likely a simple request

    Julian McMaster, Jul 26, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    344
    Kevin Spencer
    Jul 26, 2005
  2. Replies:
    2
    Views:
    346
  3. Sune
    Replies:
    10
    Views:
    583
    Martin Ambuhl
    Oct 7, 2005
  4. Jim Langston
    Replies:
    16
    Views:
    501
    AnalogFile
    Mar 22, 2006
  5. dan baker

    likely cause for status message stuck ?

    dan baker, Oct 15, 2003, in forum: Javascript
    Replies:
    3
    Views:
    113
    dan baker
    Oct 16, 2003
Loading...

Share This Page