Philip's EOF() puzzle came just as I was using a stage I'd written a
while back with a problem I hadn't figured out how to fix.  I finally
puzzled it out.

I was looking for out-of-order sequence numbers and wanted to write the
out-of-order pairs.  I had this:

  specs nowrite select second a: 73.8 . 1-* 1 select first b: 73.8 .
    if b<=a then write 1-* 1 write endif

I couldn't figure out why it always copied the last record, even though
the explicit writes were done only when the first reading station was
selected.  After inserting a bunch of literal items in different places
and watching where they came out, I finally realized:  The NOWRITE wasn't
processed in the run-out cycle because it applied only to the first
reading station!  I had to add another NOWRITE after the SELECT SECOND.

This still leaves me with a problem in the more general case, though.  If
my file should be in reverse order, then b>=a is true when the first
record hasn't reached the second reading station yet, and the initial
null record and first record are copied.  I'm not seeing how to prevent
that, except by checking a counter that I set when a record arrives at
the second reading station:

  specs select second nowrite a: 73.8 . 1-* 1 set #1:=1
    select first nowrite b: 73.8 . 
    if #1=1&b>=a then write 1-* 1 write endif

Is there a less kludgey solution?

¬R

Reply via email to