Example: An Example Using Routine Design Iteration (RSUM)
We now show how a simple routine can be developed in stages. RSUM is a function that returns the running sum of the values in its single input argument. We will present three versions of this routine, each one of which represents an improvement in functionality and flexibility.
All three versions use the function IDL_MakeTempFromTemplate(), described in Creating A Temporary Variable Using Another Variable As A Template. The result of RSUM always has the same general shape and dimensions as the input argument. IDL_MakeTempFromTemplate() encapsulates the task of creating a temporary variable of the desired type and shape using the input argument as a template.