      integer function moveon (nr, ninset)
      
c returns the record no in temp file of the next record.
c input nr is the variable that ranges from 1 -> norec
c as you move through the records in the event

      include 'basics.inc'

      include 'hold.inc'

c      character*4 chival

      save nb

      if (ninset .eq. 0) then
      
        if (nr .eq. 0) then
          nb = 0
        end if
        
      end if
      
      nr = nr + 1
      nb = nb + 1
      
      ninset = ninset + 1
      
c if temp file was needed (norec>maxrec) AND reached last record in event
c nr=norec - then rewind the temp file      
c      if (norec .gt. maxrec) then
c        if (nr .eq. norec) then
c          rewind (unit=ntemp)          
c        end if        
c      end if
      
      moveon = nb

      return
      end
