home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.comp.os.windows-xp      Actually wasn't too bad for a M$-OS      17,273 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 17,075 of 17,273   
   R.Wieser to All   
   Re: VBScript dictionary delete by index    
   08 Nov 25 09:07:57   
   
   XPost: alt.comp.lang.vbscript, alt.windows7.general   
   From: address@is.invalid   
      
   Mr. Man-wai Chang,   
      
   >> If I can use a "for each" in reverse than I already have the key (and   
   >> don't   
   >> need the index)   
   >   
   > You can first sort oDict in reverse order, but that's quite silly. :)   
      
   Yes, and it would not solve anything. :-|   (the contents are not the   
   problem)   
      
   > > I just realized I took it for granted that deleting a   
   > > key-item pair while inside a standard "for each" loop   
   > > would cause an error/crash (looping beyond the last item).   
   >   
   > That surely could be a problem for linked list, not array index.   
      
   I'm not at all sure about the first, as the "next" pointer (for the   
   iteration) doesn't need to be replaced (assuming that its retrieved and   
   stored somewhere as part of advancing to the current item).   
      
   The problem with a "for i=0 to dict.count-1" loop is that it both will skip   
   the item after the one thats being removed, and it will not adjust the "upto   
   here" part of the for loop to the new size of the array.   
      
   Looping backwards makes both of those problems disappear.   
      
   ... and thats what my head was - unneeded - stuck on. :-\   
      
   Regards,   
   Rudy Wieser   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca