Procedure MainLoop;
begin
  oldtime := SystemTime;
  repeat
    if keypressed then
    begin
      key := readkey;
      if key = #13
      then begin
             over_img2;
             login;
             over_img1;
           end;
      if (key = #0)
      then
        begin
          key := readkey;
          case key of
{ F1 }      #59  : MainHelp;
{ alt F1}   #104 : MaintainNetLog;
{ F5 }      #63  : delete_entry;
{ F10}      #68  : change_log_status;

{ HOME }    #71  : top_of_roster;
{ UArr }    #72  : scroll_down;
{ PgUp }    #73  : display_nbr(mark1);
{ End  }    #79  : end_of_roster;
{ DArr }    #80  : scroll_up;
{ PgDn }    #81  : display_nbr(mark2);
{ ^ End }   #117 : ; { CTRL-END TO EXIT THE PROGRAM }
            else key := #0;
          end;
        end
      else
        case key of
          #43  :  set_mark2;
          #45  :  set_mark1;
          else key := #0;
        end;
    end
    else
      begin
        if oldtime <> SystemTime then
        begin
          oldtime := SystemTime;
          update_time;
        end;
      end;
  until key = #117;
end;
