[INHERIT('smgdefs','BB.PEN')]
module next_message;

[global] procedure next_message;

{Step forward to the next message if there is one.  If a message is not
 displayed, then display the message that is listed after the first one
 currently listed at the top of the screen.}

var
  found : boolean;

begin
  if (dir_curr^.next = nil) then
    begin
      write_error('No more messages.');
      smg$set_physical_cursor(pasteboard,23,79);
    end
  else
    begin
      found := false;
      repeat
        dir_curr := dir_curr^.next;
        dir_start := dir_curr;
        dir_list := dir_curr;
          if (dir_curr^.number > 0) then
            begin
              found := true;
              create_message_data_list;
              data_curr := data_root;
              write_message_data;
            end;
      until found or (dir_curr^.next = nil);
      dir_list := dir_curr;
    end;
end;

end.
