I'm responding on my post above (re: why pic_names.delete(name), jumps an element in the loop. There must be a reason for this and still would like to some elucidation on the matter. However I found by creating a new array pix2bmoved =[] and doing a pix2bmoved.push[name], things seem to work right. Stuart On 7/2/06, Dark Ambient <sambient / gmail.com> wrote: > > Just out of curiosity, what did you think the connections I drew were > > meant to represent? > > I blanked on the | and ||. > > > On 7/1/06, Matthew Smillie <M.B.Smillie / sms.ed.ac.uk> wrote: > > > From what I can see, no. The first statement started is the *last* > > one ended, not the first one. > > > > if a # start of 1 > > if b # start of 2 > > > > else # else clause of 2 > > > > end # end of 2 > > else # else clause of 1 > > if c # start of 3 > > > > else # else clause of 3 > > > > end # end of 3 > > end # end of 1 > > > > It makes sense to me, I see it, I'm filing this email as a keeper > because I know I'll need to go back and refer to it. At this point the > best way to proceed for me is to worry less about all the code that > needs to be inside a block and create the scaffolds for the blocks > first with some puts statements just to makes sure things are > branching correctly. I started with the original code I posted in > this thread. I dropped the 'while' loop completely thinking it didn't > make sense considering the array loop was already in place performing > the same behaviour. > > Dir.chdir 'C:/PicturesMoved' > pic_names = Dir['C:/PicturesMoved/*.{BMP,bmp}'] > > pic_names.each do |name| # (1) array loop > puts 'Do you wish to move ' + name + 'file?,"yes" or "no" ?' > decision = gets.chomp.downcase > > if decision == 'no' # 1st if statement > puts 'This file will not be moved' > else > puts 'This file will be moved' > > end # end for 1st if statement > end # end of array loop > > This seems to work fine, however if I add this to the 'if statement' > if decision == 'no' > pic_names.delete(name) > puts 'This file will not........... > else ......... > end...... > > Then the next file in the array is skipped. As an example, if it's > 'pic1' and I say 'no', then the next name to come up for the gets > statement is 'pic 3'. I never get to decide on 'pic 2' (saying yes to > moving 'pic 1' moves the next gets to 'pic 2') > > So I decided to see what elements is assigned to > 'pic_names.delete(name). It's correct (i.e. no to pic 1, puts 'This' > + name + ' will not be moved' , returns > This C:/PicturesMoved/copypics01 .bmp will not be moved. Yet right > after that prints out I get: > Do you wish to move C:/PicturesMoved/copypics03 .bmpfile?,"yes" or "no" ? > Not sure what happened to pic2 ? > > I sense that I may still (as simple as this looks) some errors > somewhere in if / else. > > Stuart > >