Tuesday, June 12, 2007

Tricky, Tricky FOR Loops

I was just trying to write a FOR loop which would run UVCOP many times. When I ran

for i = 1 to 10; bchan i; echan i; go uvcop; end

AIPS would set bchan and echan to 1, then it would run UVCOP once, then it would set bchan and echan to 2, and end the FOR loop. I really didn't know what the problem was-- this loop should work. Then Eric told me this trick: put WAIT before the END, so that now your loop looks like this:

for i = 1 to 10; bchan i; echan i; go uvcop; wait; end

I guess what was happening was that the loop was continuing on before uvcop had finished running, and the loop was getting all confused. It worked with a WAIT!


1 comment:

amanda said...

I think you can also set dowait=1 and get the same effect.