Thanks, Glen. It almost works. You forgot to reset the total to 0 after the 
write. Adding "set #0:=0" following the write solves the problem. 

Regards, 
Richard Schuh 

 

> -----Original Message-----
> From: CMSTSO Pipelines Discussion List 
> [mailto:[email protected]] On Behalf Of Glenn Knickerbocker
> Sent: Tuesday, October 12, 2010 10:04 PM
> To: [email protected]
> Subject: Re: Summing fields in a record
> 
> On Tue, 12 Oct 2010 16:38:12 -0700, Richard Schuh wrote:
> >Is there any good pipe solution for transforming these records to 
> >"Header sum" where sum is the total of all of the fn fields
> 
> I'd use CHOP|SPLIT|JUXTAPOSE to break each field out into its 
> own record, then SPECS to add them up, something like:
> 
>   (end /) ...
>     | header: chop n
>     | field: juxtapose
>     | specs nowrite a: 1-n 1 b: N-* . set #0+=b break a print 
> #0 N write
>     | ...
>     / header:
>     | split
>     | field:
> 
> (where N = n+1).
> 
> ¬R
> 

Reply via email to