| Re: how to rerun subroutine only? [message #42726 is a reply to message #42722] |
Mon, 21 February 2005 12:57   |
Michael Wallace
Messages: 409 Registered: December 2003
|
Senior Member |
|
|
>> this is probably a beginner question, so I appreciate your patience:
>>
>> Suppose I compile & run a top level program, then it enters a
>> subroutine. Then suppose I want the code to stop somewhere in the
>> subroutine so I can plot variables or check on/plot the results of a
>> calculation... or say the subroutine encounters an error. then I might
>> change something in the subroutine and need to rerun the subroutine.
>>
>> right now I recompile the subroutine then rerun the entire code
>> starting from the beginning of the toplevel program, when all I really
>> need to do is have idl redo the calculations from the beginning of the
>> subroutine.
>>
>> is there a way to do this?
>
>
> No. :-)
>
Short and sweet response there, David. While correct, I believe it can
be expanded just a tad. :-)
If you want your code to stop running, use the 'stop' procedure. When
your code encounters a stop, it will immediately stop executing and
you'll be left in interactive mode. You can put the stop within a catch
block of the subroutine you're working on and whenever an error is
encountered the program will stop and you'll be able to look at
variables, run other commands, etc. Just make sure to remove the stop
before distributing your program.
If you want to redo calculations of the subroutine only, you'll need to
break the subroutine out into it's own file. I don't know if anyone
else does this, but I will usually first write subroutines in their own
files just so I can easily test. Once tested somewhat, I'll move the
subroutine o the proper location within the file where the subroutine
actually belongs.
-Mike
|
|
|
|