Help - stuck in loop

I have made a fundamental mistake in a function do while loop - I missed incrementing the test value to terminate the loop.  Consequently Having stareted the function I need to abort and can't.  Add to the woe, I have done a lot of program mods and should have saved my experminet a couple of hours ago. I am running latest Igor Pro version on Windows 10 Pro.

There is no abort spinning disk, shift-esc and ctrl-break do not work - just Wndows telling me "Not Responding" and blue spinning. circle.  Should the key combintaions be single one or held down?  Any other thtoughts to save a rewrite?

Help would be very much appreciated.



I am no expert on this, but I think if you lost the responses from the application then the keyboard shortcuts may be of no help. Are you doing something cpu-intensive in the loop? My only idea here would be to close as much other stuff as possible to free up system resources in the hopes that Igor catches up on windows events even though it is looping endlessly. I assume there are different threads within Igor, and the user code may run separately. User code should not lock up the application (otherwise the abort button would not make much sense either) unless it is eating resources like crazy.

If Windows says "Not responding" that means that Igor is not processing any events. That's why the abort keys aren't doing anything. What is inside your loop? Igor processes events every time through a loop (generally) and during things like wave assignments. There are a few operations in Igor that have the potential to run long, and don't check events. That's done for performance, generally, but sometimes it's just an oversight.

If you have such a long-running operation, but it finishes and Igor does something really fast, and then enters the long-running command again, you should see a flash now and then. And if that is actually happening, madly pounding Shift-Esc or Ctrl-Break might occasionally land at the right time.

And I'm curious what version of Igor you're using- I thought I had improved the ability to abort sometime in the not-too-distant past.

Looks like chozo and I were composing answers in parallel. His answer is accurate except for the threading part. User code runs in the main thread, unless you write pre-emptive threading code or if you use the Multithread keyword. In any case, some main thread code is still involved in the process and the abort must happen in the main thread.

This is a hold-over from ancient times. If I had lots of time and patience, I would love to move our function runner code to a thread. That would make the main GUI thread more responsive and possibly prevent situations like this one. But it would be a huge upset to code that is very complex and convoluted and I that didn't write.

It is my own Stupid fault for miscoding and not saving :-(  It is easily done though, and an Abort that is faster would have saved a bit of retyping.  I bit the bullet and closed it with, of couse, no save.  Here is the code that I have just reentered.

Function CountEventTypes()

    variable i,j,k,n,m
    string Folder, sysName, mywaveName, myLookStr
    variable SVCount, DFCount, SDCount

    wave /T mySystemName = SystemName  
    wave    mysystemSwitch= SystemSwitch

    Folder = "root:EventStats:Cleared:"
    i = 0
        sysName = mySystemName[i] +":"
        if (mySystemSwitch[i] ==1)
            j = 0
            mywaveName = Folder + sysName + "EventType"

            wave /T myEventType = $mywaveName
            SDCount = 0
            SVCount = 0
            DFCount = 0
                myLookstr = myEventType[j]
                if (strsearch(myLookStr,"SD",0) != -1)
                    SDCount +=1
                if (strsearch(myLookStr,"SV",0) != -1)
                    SVCount +=1
                if (strsearch(myLookStr,"DF",0) != -1)
                    DFCount +=1
                j +=1
            while (j<numpnts(myEventType))
        Print sysName + " SD Counts ", SDCount," SV Counts ", SVCount," DF Counts ", DFCount

        i +=1
    while (i < numPnts(mySystemSwitch))


It was the j+=1 that I missed.  There was nothing else running on the PC and it must have been whizzing round the loop ...

Thanks for answering.



Yeah, that is the horror of the do-while loop. I only use these when I need a dynamic end condition. Any reason you are not formulating this in for loops (where you can omit the end condition as well, but you have to deliberately leave it out of the standard format)?

Gosh. I don't see anything there that would cause the Not Responding thing to happen. How long are the strings you're searching in?

I second chozo's suggestion- use for loops. Something like

Variable i
Variable endi = numpnts(mySystemSwitch)
for (i = 0; i < endi; i++)

... code ...

    Variable j
    Variable endj = numpnts(myEventType)
    for (j = 0; j < endj; j++)
        ... code ...

... code ...

It's a lot harder to forget the increment that way, since it is part of the syntax!

You are definitely not alone in forgetting the increment, but I haven't had to abort Igor to get it to stop.

Yep.  Thats what I should have done :-(   Oh well i will put it down to (lack of ;-) experience.