home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / DATABASE / CHX8010B.LBR / CHECKC.CZ / CHECKC.C
Text File  |  2000-06-30  |  21KB  |  709 lines

  1. /*  checkc.c -- 4th source file for check register program                   */
  2.  
  3. /*  copyright (c) 1986 by Jim Woolley and WoolleyWare, San Jose, CA          */
  4.  
  5. /*  vers. 1.0, 12/85 thru 5/86
  6.  */
  7.  
  8. /*  this file contains:
  9.  *      putcursor( i, f)
  10.  *      cursorput( i, c)
  11.  *      cursorto( r, c)
  12.  *      putpos( i)
  13.  *      puttitle()
  14.  *      disheading()
  15.  *      recheading( s1, s2)
  16.  *      putquery()
  17.  *      prompt( s)
  18.  *      char putcommand( c)
  19.  *      char putcntrl( c)
  20.  *      char putnext()
  21.  *      addmoney( m3, m1, m2, add)
  22.  *      movmoney( m2, m1, credit)
  23.  *      putmoney( m)
  24.  *      putdate( d)
  25.  *      formatd( s, n, d)
  26.  *      printd( d)
  27.  *      sign( i)
  28.  *      char witch( c)
  29.  *      iscntrl( c)
  30.  *      waitesc()
  31.  *      waitkey()
  32.  *      done()
  33.  *      saveclr()
  34.  *      savedat()
  35.  *      calcbbf()
  36.  *      char help()
  37.  *      abort( s1, s2)
  38.  *      aexit()
  39.  */
  40.  
  41. #include    "a:checks.h"
  42.  
  43. putcursor( i, f)                        /*  put cursor in entry i, field f   */
  44. int i, f;
  45. {
  46.     if ( f == PAYFIELD)
  47.         Character = min( Character, strlen( Entry[ i].payee));
  48.     else Character = 0;
  49.     cursorto(( i - First + HEAD), ( Ftoc[ f] + Character));
  50. }
  51.  
  52. cursorput( i, c)                        /*  put cursor in entry i, column c  */
  53. int i, c;
  54. {
  55.     cursorto(( i - First + HEAD), c);
  56. }
  57.  
  58. cursorto( r, c)                         /*  put cursor at row r, column c    */
  59. int r, c;                               /*  0, 0 is upper-left corner        */
  60. {
  61.     int i;
  62.  
  63.     if ( Printing)
  64.         putchar( '\n');
  65.     else
  66.     {
  67.         r += Linoff;                    /*  add offset                       */
  68.         c += Coloff;
  69.         if ( Cb4flg)
  70.         {
  71.             i = r;                      /*  swap                             */
  72.             r = c;
  73.             c = i;
  74.         }
  75.         putscr( Clead1);
  76.         putpos( r);
  77.         putscr( Clead2);
  78.         putpos( c);
  79.         putscr( Ctrail);
  80.     }
  81. }
  82.  
  83. putpos( i)                              /*  send cursor position i           */
  84. int i;                                  /*  ( 0 + offset) is home            */
  85. {
  86.     char *p, s[ 4];
  87.  
  88.     if ( Ascur)                         /*  if ASCII wanted                  */
  89.     {
  90.         strcpy(( p = s), "000");        /*  template                         */
  91.         if ( Ascur < 3)
  92.             ++p;
  93.         formatd( p, Ascur, i);
  94.         puts( p);
  95.     }
  96.     else putchar( i);
  97. }
  98.  
  99. puttitle()
  100. {
  101.     char f[ FNAMSIZE];
  102.     int i, length;
  103.  
  104.     strcpy( f, Filename);
  105.     *( index( f, '.')) = '\0';          /*  truncate at dot                  */
  106.  
  107. /*  display 5 spaces on left, right justify f on column (COLS - 1), precede
  108.  *  f with 2 spaces, then center Title in the remaining area; i.e.,
  109.  *  _____<<<<<<<<<<<<<<<<<<<<<<< center Title >>>>>>>>>>>>>>>>>>>>>__A:FILENAME
  110.  */
  111.     length = strlen( Title);
  112.     i = 5 + (( COLS - FNAMSIZE - 3) - length)/2;
  113.     length += i;
  114.     while ( i--)                        /*  center title                     */
  115.         putchar( ' ');
  116.     puts( Title);
  117.     i = ( COLS - 1) - length - strlen( f);
  118.     while ( i--)                        /*  fill title line (with Ivon)      */
  119.         putchar( ' ');
  120.     puts( f);
  121.     i = HEAD - 2;
  122.     while ( i--)
  123.         putchar( '\n');
  124. }
  125.  
  126. disheading()                            /*  display heading for display()    */
  127. {
  128.     if ( !Printing)
  129.     {
  130.         cursorto( 0, 0);
  131.         putscr( Ivon);
  132.     }
  133.     puttitle();
  134.     puts( 
  135. "  Date   Payee                                      C  Amount  DEP CLR  Balance"
  136.          );
  137.     putchar( '\n');
  138.     puts( 
  139. "-------- ------------------------------------------ - -------- --- --- --------"
  140.          );
  141.     if ( !Printing)
  142.         putscr( Ivoff);
  143. }
  144.  
  145. recheading( s1, s2)                     /*  display heading for reconcile()  */
  146. char *s1, *s2;
  147. {
  148.     if ( !Printing)
  149.     {
  150.         clrscr();
  151.         putscr( Ivon);
  152.     }
  153.     puttitle();
  154.     puts( 
  155. "  Last      Balance  _____ Cleared Entries ______  _______ All Entries ________"
  156.          );
  157.     putchar( '\n');
  158.     puts(
  159. "  Date   C  Forward   Checks   Deposits   Balance   Checks   Deposits   Balance"
  160.          );
  161.     putchar( '\n');
  162.     puts( s1);
  163.     puts( s2);
  164.     if ( !Printing)
  165.         putscr( Ivoff);
  166. }
  167.  
  168. putquery()                              /*  select and display query         */
  169. {
  170.     char test, cwitch, dep;
  171.  
  172.     if ( Recno > Maxentry)
  173.     {
  174.         prompt( "Press RETURN to start a new entry, or ^J for help");
  175.         return;
  176.     }
  177.     if ( isibbf( Recno))                /*  if a BBF entry                   */
  178.     {
  179.         prompt( "Do you wish to void this entry's status as ");
  180.         puts( BBF);
  181.         puts( " (Y/N)? N");
  182.         return;
  183.     }
  184.     test = ( Field == Oldfield);
  185.     cwitch = Field;
  186.     if ( test && cwitch != DEPFIELD && cwitch != CLRFIELD)
  187.         return;
  188.     switch ( cwitch)
  189.     {
  190.     case MMFIELD:
  191.         prompt( "Enter month");
  192.         break;
  193.     case DDFIELD:
  194.         prompt( "Enter date");
  195.         break;
  196.     case YYFIELD:
  197.         prompt( "Enter year");
  198.         break;
  199.     case PAYFIELD:
  200.         prompt( "Enter/edit payee    ( INSERT ");
  201.         puts( Inserton ? "ON )" : "OFF )");
  202.         break;
  203.     case CATFIELD:
  204.         prompt( "Enter category");
  205.         break;
  206.     case AMTFIELD:
  207.         prompt( "Enter/calculate amount");
  208.         cursorto(( HEAD - 4), ( AMTCOL - 9));
  209.         puts( "MEMORY = ");
  210.         putmoney( &Memory);
  211.         break;
  212.     case DEPFIELD:
  213.         prompt( "Is entry a deposit (Y/N)? ");
  214.         dep = Entry[ Recno].deposit;
  215.         goto yesno;
  216.     case CLRFIELD:
  217.         prompt( "Has entry cleared the bank (Y/N)? ");
  218.         dep = Entry[ Recno].clear;
  219. yesno:  putchar( dep ? 'Y' : 'N');
  220.         break;
  221.     }
  222.     return;
  223. }
  224.  
  225. prompt( s)                              /*  prompt for entry                 */
  226. char *s;
  227. {
  228.     int c;
  229.  
  230.     cursorto(( HEAD - 4), 0);
  231.     puts( s);
  232.     clreol( c = strlen( s));
  233.     if ( !( *Eraeol))                   /*  if no Eraeol string              */
  234.         cursorto(( HEAD - 4), c);       /*  return cursor                    */
  235.     Oldfield = -1;
  236. }
  237.  
  238. char putcommand( c)                     /*  display command                  */
  239. char c;                                 /*  return TRUE if cursor moved      */
  240. {
  241.     switch ( c)
  242.     {
  243.     case CTRLK:  case CTRLQ:  case CTRLC:  case CTRLR:
  244.     case CTRLB:  case CTRLO:  case CTRLP:
  245.         cursorto( 0, 0);
  246.         putscr( Ivon);
  247.         puts( CLRCOM);
  248.         putchar( '\r');
  249.         putcntrl( c);
  250.         putscr( Ivoff);
  251.         return ( TRUE);
  252.     default:
  253.         return ( FALSE);
  254.     }
  255. }
  256.  
  257. char putcntrl( c)                       /*  display control char             */
  258. char c;                                 /*  return ( c + CTRLTOA) or DEL     */
  259. {
  260.     if ( c != DEL)
  261.     {
  262.         putchar( '^');
  263.         putchar( c += CTRLTOA);
  264.     }
  265.     else puts( "DEL");
  266.     return ( c);
  267. }
  268.  
  269. char putnext()                          /*  display next command character   */
  270. {                                       /*  return upper case character      */
  271.     char c;
  272.  
  273.     putscr( Ivon);
  274.     if ( isprint( c = getchar()))
  275.     {
  276.         putchar( c);
  277.         c = toupper( c);
  278.     }
  279.     else c = putcntrl( c);
  280.     putscr( Ivoff);
  281.     return ( c);
  282. }
  283.  
  284. addmoney( m3, m1, m2, add)              /*  get m3 = m1 + m2 if add = TRUE   */
  285. struct money *m3, *m1, *m2;             /*  get m3 = m1 - m2 if add = FALSE  */
  286. char add;
  287. {
  288.     int d, c, sd;
  289.  
  290.     if ( add)
  291.     {
  292.         d = m1->dollar + m2->dollar;
  293.         c = m1->cent + m2->cent;
  294.     }
  295.     else
  296.     {
  297.         d = m1->dollar - m2->dollar;
  298.         c = m1->cent - m2->cent;
  299.     }
  300.     if ( d && ( sd = sign( d)) != sign( c))
  301.     {
  302.         d -= sd;
  303.         if ( sd < 0)
  304.             c -= 10000;
  305.         else c += 10000;
  306.     }
  307.     m3->dollar = d + c/10000;
  308.     m3->cent = c%10000;
  309. }
  310.  
  311. movmoney( m2, m1, credit)               /*  set m2 = m1 if credit = TRUE     */
  312. struct money *m2, *m1;                  /*  else, set m2 = abs( m1)          */
  313. char credit;
  314. {
  315.     if ( credit)
  316.     {
  317.         m2->dollar = m1->dollar;
  318.         m2->cent = m1->cent;
  319.     }
  320.     else
  321.     {
  322.         m2->dollar = abs( m1->dollar);
  323.         m2->cent = abs( m1->cent);
  324.     }
  325. }
  326.  
  327. putmoney( m)                            /*  format and display money         */
  328. struct money *m;
  329. {
  330.     char s[ 10];
  331.     int is, id, ic;                     /*  int is assumed to be 16 bits     */
  332.     struct money w;
  333.  
  334.     if (( id = m->dollar) < -99 || 999 < id)
  335.     {
  336.         w.dollar = 0;
  337.         w.cent = 50;                    /*  round-off to nearest dollar      */
  338.         addmoney( &w, m, &w, ( id > 0));
  339.         id = w.dollar;
  340.         ic = w.cent;
  341.         is = 6;
  342.         strcpy( s, "       0 ");        /*  template                         */
  343.     }
  344.     else
  345.     {
  346.         ic = m->cent;
  347.         is = 3;
  348.         strcpy( s, "    0.00 ");        /*  template                         */
  349.     }
  350.     if ( id < 0 || ic < 0)
  351.     {
  352.         id = abs( id);
  353.         ic = abs( ic);
  354.         s[ 0] = '(';
  355.         s[ 8] = ')';
  356.     }
  357.     if ( id)
  358.     {
  359.         formatd( s, is, id);
  360.         s[ is] = '0';                   /*  fill                             */
  361.     }
  362.     formatd(( s + is), 2, ic/100);
  363.     if ( is == 3)
  364.         formatd(( s + 6), 2, ic%100);
  365.     puts( s);
  366. }
  367.  
  368. putdate( d)                             /*  format and display date          */
  369. struct calendar *d;
  370. {
  371.     char s[ 10];
  372.  
  373.     strcpy( s, " 0/00/00 ");            /*  template                         */
  374.     formatd( s, 2, d->mm);
  375.     formatd(( s + 3), 2, d->dd);
  376.     formatd(( s + 6), 2, d->yy);
  377.     puts( s);
  378. }
  379.  
  380. formatd¿ s¼ n¼ d⌐                       /¬  forma⌠ ε digit≤ oµ Σ int∩ ≤      */
  381. char s[];                               /*  like sprintf( s, "%nd", d)       */
  382. int n, d;                               /*  d is assumed to be positive      */
  383. {                                       /*  and n decimal digits or less     */
  384.     while ( d && n--)                   /*  s is assumed to be initialized   */
  385.     {                                   /*  with an appropriate template     */
  386.         s[ n] = '0' + d%10;
  387.         d /= 10;
  388.     }
  389. }
  390.  
  391. printd( d)                              /*  print d in decimal               */
  392. int d;                                  /*  like printf( "%d", d)            */
  393. {                                       /*  d is assumed to be positive      */
  394.     int n;                              /*  see K & R, p. 85                 */
  395.  
  396.     if ( n = d/10)
  397.         printd( n);                     /*  recursion for leading digits     */
  398.     putchar( '0' + d%10);               /*  trailing digit                   */
  399. }
  400.  
  401. sign( i)                                /*  return 1 with sign of i          */
  402. {
  403.     return ( i < 0 ? -1 : 1);
  404. }
  405.  
  406. char witch( c)                          /*  return control character         */
  407. char c;                                 /*  else return CR                   */
  408. {
  409.     if ( iscntrl( c))
  410.         return ( c);
  411.     return ( '\r');
  412. }
  413.  
  414. iscntrl( c)                             /*  is c a control char?             */
  415. char c;
  416. {
  417.     return ( c < ' ' || c == DEL);
  418. }
  419.  
  420. waitesc()                               /*  wait for ESCAPE key              */
  421. {
  422.     puts( "  --  Press ESCAPE to continue");
  423.     putchar( BEL);
  424.     while ( getchar() != ESC)
  425.         continue;
  426. }
  427.  
  428. waitkey()                               /*  wait for CTRL-C or other key     */
  429. {
  430.     puts( "  --  ^C to quit, or any other key to continue");
  431.     putchar( BEL);
  432.     if ( getchar() == CTRLC)
  433.         aexit();                        /*  never return                     */
  434. }
  435.  
  436. done()                                  /*  save and archive check register  */
  437. {
  438.     if ( saveclr())
  439.         return;
  440.     calcbbf();
  441.     if ( savedat())
  442.     {
  443.         Recno = Maxentry + 1 - PAGE;    /*  initialize gobottom()            */
  444.         First = Recno - PAGE;
  445.         Last = First - 1;
  446.         Field = 0;
  447.         gobottom();                     /*  redisplay                        */
  448.         return;
  449.     }
  450.     aexit();                            /*  no return                        */
  451. }
  452.  
  453. saveclr()                               /*  save cleared entries             */
  454. {                                       /*  return TRUE if bad disk          */
  455.     char *p;
  456.     char tempname[ FNAMSIZE], bufin[ BUFSIZ], bufout[ BUFSIZ];
  457.     int i, j, count, oldcount, imax, total, compdate();
  458.  
  459.     typcat( Filename, CLRTYP);
  460.     count = 0;                          /*  count number of cleared entries  */
  461.     for ( i = 0; i <= Maxentry; ++i)
  462.         if ( Entry[ i].clear)
  463.             ++count;
  464.     if ( !count)
  465.     {
  466.         prompt( "No change necessary to ");
  467.         puts( Filename);
  468.         puts( " - ");
  469.         return ( FALSE);
  470.     }
  471.     prompt( "");
  472.     reorder( 0, compdate);
  473.     strcpy( tempname, Filename);
  474.     typcat( tempname, TMPTYP);
  475.     resetdsk();
  476.     if ( fcreat( tempname, bufout) == ERROR)
  477.     {
  478.         createrr( tempname);
  479.         return ( TRUE);
  480.     }
  481.     if ( fopen( Filename, bufin) == ERROR)
  482.         oldcount = 0;
  483.     else
  484.     {
  485.         oldcount = getw( bufin);         /*  records in CLR file              */
  486.         getw( bufin);                   /*  filler                           */
  487.         getw( bufin);                   /*  filler                           */
  488.     }
  489.     if ( imax = max( 0, ( RECSIZ*( oldcount + count - CLRSIZE))))
  490.     {
  491.         prompt( Filename);
  492.         puts( " is full.  OK to discard oldest cleared entries (Y/N)? ");
  493.         if ( !getyesno( YES))
  494.             return ( FALSE);
  495.         for ( i = imax; i; --i)
  496.             getc( bufin);               /*  discard old records              */
  497.     }
  498.     imax = RECSIZ*oldcount - imax;
  499.     total = min( CLRSIZE, ( oldcount + count));
  500.     putw( total, bufout);               /*  record new total record count    */
  501.     putw( 0, bufout);                   /*  filler                           */
  502.     putw( 0, bufout);                   /*  filler                           */
  503.     for ( i = imax; i; --i)             /*  transfer old records             */
  504.         if ( putc( getc( bufin), bufout) == ERROR)
  505.             goto error;
  506.     if ( oldcount)
  507.         fclose( bufin);
  508.     for ( i = 0; i <= Maxentry; ++i)
  509.     {
  510.         if ( Entry[ i].clear)
  511.         {
  512.             p = &Entry[ i];
  513.             for ( j = RECSIZ; j; --j)
  514.                 if ( putc( *p++, bufout) == ERROR)
  515.                     goto error;
  516.         }
  517.     }
  518.     if ( fflush( bufout) == ERROR)      /*  make sure it is all saved        */
  519.         goto error;
  520.     fclose( bufout);
  521.     prompt( "Do you wish to print an audit trail of cleared entries (Y/N)? ");
  522.     if ( getyesno( NO) && setlst())
  523.     {
  524.         disheading();
  525.         for ( i = 0; i <= Maxentry; ++i)
  526.         {
  527.             if ( Entry[ i].clear)
  528.             {
  529.                 Balance[ i].dollar = Balance[ i].cent = 0;
  530.                 putrecord( i);          /*  print cleared entry              */
  531.             }
  532.         }
  533.         resetlst();
  534.     }
  535.     unlink( Filename);
  536.     if ( rename( tempname, Filename) == ERROR)
  537.     {
  538.         prompt( "Could not rename ");
  539.         puts( tempname);
  540.         puts( " to ");
  541.         puts( Filename);
  542.         waitesc();
  543.         strcpy( Filename, tempname);
  544.     }
  545.     prompt( Filename);
  546.     puts( " has ");
  547.     printd( count);
  548.     puts( " new entries (");
  549.     printd( total);
  550.     puts( " total) - ");
  551.     return ( FALSE);                    /*  normal return                    */
  552.  
  553. error:
  554.     fclose( bufout);
  555.     writerr( tempname);
  556.     return ( TRUE);
  557. }
  558.  
  559. savedat()                               /*  save all entries                 */
  560. {                                       /*  return TRUE if bad disk          */
  561.     char *p, tempname[ FNAMSIZE], backname[ FNAMSIZE], bufout[ BUFSIZ];
  562.     int i, j;
  563.  
  564.     typcat( Filename, DATTYP);
  565.     strcpy( tempname, Filename);
  566.     typcat( tempname, TMPTYP);
  567.     strcpy( backname, Filename);
  568.     typcat( backname, BAKTYP);
  569.     resetdsk();
  570.     if ( fcreat( tempname, bufout) == ERROR)
  571.     {
  572.         createrr( tempname);
  573.         return ( TRUE);
  574.     }
  575.     putw(( Maxentry + 1), bufout);      /*  record number of entries         */
  576.     putw( Memory.dollar, bufout);       /*  record Memory                    */
  577.     putw( Memory.cent, bufout);
  578.     for ( i = 0; i <= Maxentry; ++i)
  579.     {
  580.         p = &Entry[ i];
  581.         for ( j = RECSIZ; j; --j)
  582.             if ( putc( *p++, bufout) == ERROR)
  583.                 goto error;
  584.     }
  585.     if ( fflush( bufout) == ERROR)      /*  make sure it is all saved        */
  586.         goto error;
  587.     fclose( bufout);
  588.     unlink( backname);
  589.     rename( Filename, backname);
  590.     rename( tempname, Filename);
  591.     puts( Filename);
  592.     puts( " has ");
  593.     printd( Maxentry + 1);
  594.     puts( " entries");
  595.     return ( FALSE);                    /*  normal return                    */
  596.  
  597. error:
  598.     fclose( bufout);
  599.     writerr( tempname);
  600.     return ( TRUE);
  601. }
  602.  
  603. calcbbf()                               /*  calculate BBF for each category  */
  604. {                                       /*  BBF = BALANCE BROUGHT FORWARD    */
  605.     char c, nbr[ DEL];
  606.     int i, j, count, new;
  607.     struct record *e;
  608.     struct money sum;
  609.     struct calendar maxdate;
  610.  
  611.     setmem( nbr, DEL, 0);               /*  initialize                       */
  612.     for ( j = 0; j <= Maxentry; ++j)    /*  identify categories              */
  613.     {
  614.         e = &Entry[ j];
  615.         c = e->category;
  616.         if ( c & 0x80)                  /*  if BBF category                  */
  617.             e->clear = TRUE;            /*      mark for summation           */
  618.         if ( e->clear)                  /*  count cleared entries            */
  619.             ++nbr[ c & 0x7f];           /*      for each category            */
  620.     }
  621.     new = 0;
  622.     for ( i = ' '; i < DEL; ++i)        /*  sum cleared categories           */
  623.     {                                   /*      in ASCII order               */
  624.         if ( !nbr[ i])                  /*  if category does not exist       */
  625.             continue;                   /*      next category                */
  626.         count = 0;
  627.         maxdate.mm = maxdate.dd = maxdate.yy = sum.dollar = sum.cent = 0;
  628.         for ( j = 0; j <= Maxentry; ++j)
  629.         {
  630.             e = &Entry[ j];
  631.             if ( !( e->clear) || ( e->category & 0x7f) != i)
  632.                 continue;               /*  next entry                       */
  633.             addmoney( &sum, &sum, &( e->amount), e->deposit);
  634.             datemax( &maxdate, &( e->date));
  635.             if ( j < Maxentry)          /*  delete cleared category          */
  636.                 movmem( &Entry[ j + 1], e, ( Maxentry - j)*RECSIZ);
  637.             --Maxentry;
  638.             --j;                        /*  Entry[ j + 1] moved up           */
  639.             if ( ++count == nbr[ i])    /*  if all entries for this category */
  640.                 break;                  /*      break j loop over entries    */
  641.         }                               /*  end j loop over entries          */
  642.         e = &Entry[ new];               /*  insert new BBF category          */
  643.         if ( new <= Maxentry)
  644.             movmem( e, &Entry[ new + 1], ( Maxentry - new + 1)*RECSIZ);
  645.         ++Maxentry;
  646.         ++new;
  647.         if ( sum.dollar < 0 || sum.cent < 0)
  648.             e->deposit = FALSE;
  649.         else e->deposit = TRUE;
  650.         movmoney( &( e->amount), &sum, e->deposit);
  651.         e->date.mm = maxdate.mm;
  652.         e->date.dd = maxdate.dd;
  653.         e->date.yy = maxdate.yy;
  654.         e->clear = FALSE;
  655.         e->category = i | 0x80;
  656.         strcpy( e->payee, BBF);
  657.     }                                   /*  end i loop over categories       */
  658. }
  659.  
  660. char help()                             /*  display help screen              */
  661. {
  662.     char c, s[ MAXLINE], f[ FNAMSIZE], buf[ BUFSIZ], *fgets();
  663.     int i;
  664.  
  665.     strcpy( f, DEFNAM);
  666.     typcat( f, SCRTYP);
  667.     if ( fopen( f, buf) == ERROR)
  668.     {
  669.         openerr( f);
  670.         return( 0);
  671.     }
  672.     cursorto( 0, 0);
  673.     putscr( Ivon);
  674.     for ( i = 6; i-- && fgets( s, buf); )
  675.         puts( s);
  676.     putscr( Ivoff);
  677.     fclose( buf);
  678.     putcursor( Recno, Field);
  679.     c = getchar();                      /*  wait for another command         */
  680.     for ( i = 0; i < HEAD; ++i)         /*  clear top of screen              */
  681.     {
  682.         cursorto( i, 0);
  683.         clreol( 0);
  684.     }
  685.     disheading();
  686.     putcursor( Recno, Field);
  687.     return ( c);
  688. }
  689.  
  690. abort( s1, s2)                          /*  abort with two part message      */
  691. char *s1, *s2;
  692. {
  693.     cursorto(( ROWS - 2), 0);
  694.     clreol( 0);
  695.     putchar( '\r');
  696.     puts( s1);
  697.     puts( s2);
  698.     putchar( BEL);
  699.     aexit();                            /*  no return                        */
  700. }
  701.  
  702. aexit()                                 /*  clear last line and exit         */
  703. {
  704.     cursorto(( ROWS - 1), 0);
  705.     clreol( 0);
  706.     cursorto(( ROWS - 2), 0);
  707.     exit();
  708. }
  709.