running sum code

I'd like to take create a running sum(cumulative plot) from data points from an old wave and plot them as a new wave.
ex. if points in old wave are 1,1,2,3 ----------- new wave would be 1,2,4,7

This is the code that I need help with:

#pragma rtGlobals=3     // Use modern global access method and strict wave access.


///

Function go()

Wave new
Wave old_wave

Make /O new

Variable run_sum = 0
Variable curr_val
Variable p=0
curr_val = old_wave[p]

do new[p] = run_sum + old_wave[p]
p+=1
run_sum += curr_val

while (p <= numpnts(old_wave))

return curr_val
display new

end
You can save yourself the trouble and use the Integrate operation, just make sure that your input wave has default scaling.
Duplicate/O old_wave,newWave
Integrate/meth=0 newWave
Display newWave


If you insist on writing an explicit loop you may want to stay away from using 'p' as an index as it has other uses.

A.G.
WaveMetrics, Inc.