Set tag to previous value of tag in earlier record


How do I set the value of a tag to be carried over from the last captured value of that tag in the previous record. Is there a way to set a variable which I can reference later in the script?

For example, in pages for classical music, some sites don't repeat the "Composer" or "Work" if these haven't changed from the previous track on the disc.

Examples (stripped of HTML in the format Track, Composer, Work, Movement:

1,Krzysztof Penderecki,Symphony No.7,Magnus Dominus
2,,,Si oblitus fuero tui Jerusalem
3,,,De profundis
4,,,Haec dicit Dominus


How do I carry forward the value of the "composer" and "work" variables? I've tried:

outputto "Work"
sayoutput "Work"

but the contents of the whole buffer is added to itself not the value of the last input to the buffer, i.e., for the third track I'll end up with 4 values, for the 4th track 8 values. This is not a problem if all the tracks on the disc have the same composer and work (I'll just get 2**(tracks-1) repeats and the excess will be ignored when values are written to the individual track records).

But if say the first 3 tracks are a symphony by Schubert, and next 3 tracks are a symphony by Brahms, by the time I get to process the Brahms, I'll already have 4 values each for "composer" and "work" and the entries for the 4th track are displaced one value to the right. This get progressively worse as the track number increases.

I'm no programmer, so my skills are fairly rudimentary. I'd appreciate any suggestions for getting around this.