View Single Post
Old May 6th, 2007, 2:41 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
If will fire when the return from the last recursive call is made. Whether or not it fires subsequently will depend upon whether or not any subsequent calls are made. Here's your sequence: You begin with imageNum = 1, image "xx". Because of that, you increment imageNum and make a recursive call. The image will not be "xx", so you don't make another call, but return from the first recursive call. At that point you will get a "yy" alert, then return from the original call. The imgNumber will be 4 and mainPic.src will be 28.jpg.

I might suggest that there is little use for recursion here. Possibly you're just playing around. If so, avail yourself of more alerts in more paths, with more information.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote