home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1 / HamRadio.cdr / cw / kamrtty / kam-log.pas < prev    next >
Pascal/Delphi Source File  |  1988-04-06  |  6KB  |  223 lines

  1. procedure open_log(log: file_type);
  2. begin
  3.   assign(logfile,log);
  4.   {$I-}
  5.   reset(logfile);
  6. end;
  7.  
  8. procedure check_dup;
  9. var duplog : file_type;
  10.     dupline,
  11.     callsign : msg_type;
  12.     log_name : file_type;
  13. begin
  14.   case mode of
  15.     CW    : log_name := cw_log_file;
  16.     RTTY  : log_name := rtty_log_file;
  17.     ASCII : log_name := ascii_log_file;
  18.   end;
  19.   halt_xmt;
  20.   save_screen;
  21.   aux_color;
  22.   frame(1,3,80,6);
  23.   window(2,4,79,5);
  24.   clrscr;
  25.   get_file_name(duplog,1,1,'View log ['+log_name+']',2,4,79,5,4);
  26.   if (duplog = '') then duplog := log_name;
  27.   open_log(duplog);
  28.   if (IOresult <> 0)
  29.   then
  30.     begin
  31.       writeln; writeln('File not found ... press any key to continue.');
  32.       wait_for_key;
  33.     end
  34.   else
  35.     begin
  36.       clrscr;
  37.       write('Enter callsign for dup check ... ');
  38.       readln(callsign);
  39.       UpperCase(callsign);
  40.       repeat
  41.         readln(logfile,dupline);
  42.         UpperCase(dupline);
  43.       until (pos(callsign,dupline) > 0) OR Eof(logfile) ;
  44.       if (pos(callsign,dupline) > 0) then
  45.       begin
  46.         clrscr;
  47.         writeln(dupline);
  48.         write('Press any key to continue ...');
  49.         wait_for_key;
  50.       end;
  51.     end;
  52.   close(logfile);
  53.   full_window;
  54.   restore_screen;
  55. end;
  56.  
  57. procedure view_log;
  58. label endview;
  59. var viewlog : file_type;
  60.     viewline : string[80];
  61.     i : integer;
  62.     log_name : file_type;
  63. begin
  64.   case mode of
  65.     CW    : log_name := cw_log_file;
  66.     RTTY  : log_name := rtty_log_file;
  67.     ASCII : log_name := ascii_log_file;
  68.   end;
  69.   halt_xmt;
  70.   save_screen;
  71.   aux_color;
  72.   frame(1,3,80,20);
  73.   window(2,4,79,19);
  74.   clrscr;
  75.   get_file_name(viewlog,1,1,'View log ['+log_name+']',2,4,79,19,4);
  76.   if (viewlog = '') then viewlog := log_name;
  77.   open_log(viewlog);
  78.   if (IOresult <> 0)
  79.   then
  80.     begin
  81.       writeln; writeln('File not found ... press any key to continue.');
  82.       wait_for_key;
  83.     end
  84.   else
  85.     begin
  86.       i := 0;
  87.       clrscr;
  88.       repeat
  89.         readln(logfile,viewline);
  90.         writeln(viewline);
  91.         i := i + 1;
  92.         if (i = 15) then
  93.         begin
  94.           write('<ESC> escape ... <RET> continue ...');
  95.           repeat
  96.             qkey := readkey;
  97.             if (qkey = #0) then qkey := readkey;
  98.           until (qkey in [#27,#13]);
  99.           if (qkey = #27) then goto endview;
  100.           gotoxy(1,16); ClrEol;
  101.           i := 0;
  102.         end;
  103.       until (Eof(logfile));
  104.       gotoxy(1,16); write('Press any key to continue..');
  105.       wait_for_key;
  106.     end;
  107. endview:
  108.   close(logfile);
  109.   full_window;
  110.   restore_screen;
  111. end;
  112.  
  113. procedure update_log;
  114. label save_fault;
  115. var i : integer;
  116.     dummy : string[80];
  117.     log_name : file_type;
  118. begin
  119.   case mode of
  120.     CW    : log_name := cw_log_file;
  121.     RTTY  : log_name := rtty_log_file;
  122.     ASCII : log_name := ascii_log_file;
  123.   end;
  124.   if (qso_nbr <> 0) then
  125.   begin
  126.     halt_xmt;
  127.     save_screen;
  128.     aux_color;
  129.     frame(19,7,51,17);
  130.     window(20,8,50,16);
  131.     clrscr;
  132.     gotoxy(5,4); writeln('UPDATING ',log_name);
  133.     open_log(log_name);
  134.     if (IOresult <> 0) then
  135.       begin
  136.         rewrite(logfile);
  137.         if (IOresult <> 0) then
  138.           begin
  139.             writeln('Unable to open file ',log_name);
  140.             delay(2000);
  141.             goto save_fault;
  142.           end
  143.         else
  144.           begin
  145.             writeln(logfile,
  146. '  DATE    TIME      FREQ  PWR   RST     CALL           COMMENTS');
  147.             writeln(logfile,
  148. '                              OUT  IN');
  149.             writeln(logfile);
  150.           end;
  151.       end
  152.     else
  153.       begin
  154.         while not eof(logfile) do readln(logfile,dummy);
  155.         append(logfile);
  156.       end;
  157.   for i := 1 to qso_nbr do
  158.     begin
  159.       write(logfile,logbook[i].date:8);
  160.       write(logfile,logbook[i].time:6);
  161.       write(logfile,logbook[i].freq:10);
  162.       write(logfile,logbook[i].power:5);
  163.       write(logfile,logbook[i].rst_out:4);
  164.       write(logfile,logbook[i].rst_in:4);
  165.       write(logfile,logbook[i].callsign:8);
  166.       writeln(logfile,logbook[i].comments:31);
  167.       if (IOresult <> 0) then goto save_fault;
  168.     end;
  169.   qso_nbr := 0;
  170. save_fault:
  171.   close(logfile);
  172.   full_window;
  173.   restore_screen;
  174.   end;
  175. end;
  176.  
  177. procedure xxx(nbr : integer);
  178. var  i : integer;
  179. begin
  180.   for i := 1 to nbr do write('x');
  181.   for i := 1 to nbr do write(chr(8));
  182. end;
  183.  
  184. procedure log_qso;
  185. begin
  186.   halt_xmt;
  187.   save_screen;
  188.   aux_color;
  189.   frame(14,7,66,19);
  190.   window(15,8,65,18);
  191.   clrscr;
  192.   qso_nbr := qso_nbr + 1;
  193.   gotoxy(1,1); write('Date .............. ');
  194.   gotoxy(1,2); write('Time .............. ');
  195.   gotoxy(1,3); write('Freq .............. ');
  196.   gotoxy(1,4); write('Power ............. ');
  197.   gotoxy(1,5); write('Outgoing RST ...... ');
  198.   gotoxy(1,6); write('Incoming RST ...... ');
  199.   gotoxy(1,7); write('Call sign worked .. ');
  200.   gotoxy(1,8); write('Comments [name, etc]');
  201.   gotoxy(20,1); xxx(8); readln(logbook[qso_nbr].date);
  202.   if (logbook[qso_nbr].date = '') then
  203.     logbook[qso_nbr].date := date;
  204.   gotoxy(20,1); ClrEol; write(logbook[qso_nbr].date);
  205.   gotoxy(20,2); xxx(8); readln(logbook[qso_nbr].time);
  206.   if (logbook[qso_nbr].time = '') then
  207.       logbook[qso_nbr].time := time;
  208.   gotoxy(20,2); ClrEol; write(logbook[qso_nbr].time);
  209.   gotoxy(20,3); xxx(8); readln(logbook[qso_nbr].freq);
  210.   gotoxy(20,3); ClrEol; write(logbook[qso_nbr].freq);
  211.   gotoxy(20,4); xxx(4); readln(logbook[qso_nbr].power);
  212.   gotoxy(20,4); ClrEol; write(logbook[qso_nbr].power);
  213.   gotoxy(20,5); xxx(3); readln(logbook[qso_nbr].rst_out);
  214.   gotoxy(20,5); ClrEol; write(logbook[qso_nbr].rst_out);
  215.   gotoxy(20,6); xxx(3); readln(logbook[qso_nbr].rst_in);
  216.   gotoxy(20,6); ClrEol; write(logbook[qso_nbr].rst_in);
  217.   gotoxy(20,7); xxx(8); readln(logbook[qso_nbr].callsign);
  218.   gotoxy(20,7); ClrEol; write(logbook[qso_nbr].callsign);
  219.   gotoxy(10,10); xxx(30); readln(logbook[qso_nbr].comments);
  220.   restore_screen;
  221.   if (qso_nbr = 100) then update_log;
  222. end;
  223.