home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / CSSRC / FLDPUSHL.C < prev    next >
C/C++ Source or Header  |  1990-03-28  |  1KB  |  53 lines

  1. /*
  2.     fldpushl.c        5/11/88
  3.  
  4.     % field_PushLeft
  5.  
  6.     C-scape 3.2
  7.     Copyright (c) 1986, 1987, by Oakland Group, Inc.
  8.     ALL RIGHTS RESERVED.
  9.  
  10.     Revision History:
  11.     -----------------
  12.      3/28/90 jmd    ansi-fied
  13. */                    
  14.  
  15. #include "field.h"
  16.  
  17. char field_PushLeft(field_type f, int fpos, char c)
  18. /*
  19.     modifies:   the field.
  20.     effects:    inserts the scancode at fpos, pushes the
  21.                    characters to the left:
  22.                 |x  hell mom|
  23.                        ^
  24.                 |  hello mom|      ---> return('x');
  25.                        ^ 
  26.     returns:    the character that falls off the edge.  If nothing falls off
  27.                  the edge, return '\0'.
  28. */
  29. {
  30.     char     edge_char;
  31.     int     recpos;
  32.  
  33.     /* Remember the edge character. */
  34.     edge_char = f->record[0];
  35.  
  36.     /* push to the left */
  37.     for (recpos = 0; recpos < fpos; recpos++) {
  38.         f->record[recpos] = f->record[recpos+1];
  39.         if (f->merge != NULL) {
  40.             f->merge[f->r2m[recpos]] = (f->record[recpos+1] != '\0') ? 
  41.                                         f->record[recpos+1] :
  42.                                         MRGPADCHAR;
  43.         }
  44.     }
  45.  
  46.     /* insert the char */
  47.     field_SetChar(f, fpos, c);
  48.  
  49.     return(edge_char);
  50. }
  51.  
  52.  
  53.