problem with PauseforUser

My need is to quickly move thru a stack of images, pausing on each until the cursor is moved and the "Log" button has been hit. I have one set of 2 Functions that allows correct use of the cursor and Log button but fails to bring up a new image.
I have another set of Functions that loops thru the images but fails to use the cursor and Log.
I haven't written any code for 3 years and am rusty--so assume I am doing something stupid. Please help

----------
The first set of Functions
FUNCTION BFTrackStack(CtrlName): ButtonControl                  //DFB 11.10.12 
String CtrlName
VariableTrackFlag=1,LogDoneFlag=0                                                              
Variable/G  filecount, StackSize
Variable  filecount=0
String KeyID=""

wave KeyIDList                      //list of the names of the images in the stack
filecount=0
LogDoneFlag=0
keyID=keyIDList[0] + ".tif"
    print "keyID1 = ", KeyID
    duplicate/o $(keyID), w
    NewImage/S=0 w
    showinfo
     DoWindow/C Log2                //pop-up termination panel
     Button TSLogItNow2 size={33,20}, pos={5,5}, proc=LogIt, title="Log"

If (LogDoneFlag==1)         //have returned from Logit
   Do
                    //If (LogDoneFlag==1)           //have returned from Logit
    keyID=keyIDList[filecount] + ".tif"
    print "keyID2 = ", KeyID
    duplicate/o $(keyID), w              //update the image
     print "return from Logit, LogDoneFlag, filecount = ", LogdoneFlag, filecount
    LogDoneFlag=0
    filecount=filecount+1
   while (filecount<=StackSize)    
endif  
end
----------------------------------------------
FUNCTION Logit(CtrlName2): ButtonControl           
string CtrlName2
Variable/G  filecount, LogDoneFlag
                    //DoUpdate/E=1/w=logit
    make/n=StackSize xloc, yloc
    xloc[filecount]=xcsr(A)
    yloc[filecount]=vcsr(A)
                    //DoWindow/K Graph0
                    //DoWindow/K Log2
                    //print "Logitfilecount4= ", filecount
    LogDoneFlag=1
    filecount=filecount+1
    print "Logitfilecount, LogDoneFlag(logit) = ", filecount, LogDoneFlag
    beep
end
--------------------------------------------------------
Function BFStackLogBC(CtrlName): ButtonControl
String CtrlName
//NewPanel/K=2  as "Log"
DoWindow/C LogCentroidPanel     //pop-up termination panel
movewindow/w=SelectOutlierPanel 300,300,500,360
DrawText 17,30,"Drag Cursor_A to Centroid, then Click on Log"
end
-------------------------------------- 
-------------------------------------

The second set

FUNCTION BFTrackStack(CtrlName): ButtonControl                  //DFB 11.10.12 
String CtrlName
Variable TrackFlag=1,LogDoneFlag=0                                                             
Variable/G  filecount, StackSize
Variable  filecount=0
String KeyID=""

wave KeyIDList                      //list of the names of the images in the stack
filecount=0
LogDoneFlag=0

keyID=keyIDList[0] + ".tif"
    print "keyID1 = ", KeyID
    duplicate/o $(keyID), w
    NewImage/S=0 w
    showinfo
     DoWindow/C Log2                //pop-up termination panel
     Button TSLogItNow2 size={33,20}, pos={5,5}, proc=LogIt, title="Log"
PauseForUser/C log2
 Do
    keyID=keyIDList[filecount] + ".tif"
    print "keyID2 = ", KeyID
    duplicate/o $(keyID), w              //update the image
    print "return from Logit, LogDoneFlag, filecount = ", LogdoneFlag, filecount
        LogDoneFlag=0
    filecount=filecount+1
   while (filecount<=StackSize)    
end
--------------------------------------
FUNCTION Logit(CtrlName2): ButtonControl           
string CtrlName2
Variable/G LogDoneFlag
//DoUpdate/E=1/w=logit
    wave xloc
    wave yloc
    xloc[filecount]=xcsr(A)
    yloc[filecount]=vcsr(A)
    //DoWindow/K Graph0
    //DoWindow/K Log2
    //print "Logitfilecount4= ", filecount
    LogDoneFlag=1
    filecount=filecount+1
    print "Logitfilecount, LogDoneFlag(logit) = ", filecount, LogDoneFlag
    beep
end
--------------------------------------------