home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c185 / 1.ddi / FUNCS.EXE / CSCAPE / SOURCE / FNSLONG.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-07  |  1.8 KB  |  77 lines

  1. /*
  2.     fnslong.c             10/2/87
  3.  
  4.     % slong_funcs
  5.  
  6.     Long editing functions.
  7.     These funcs edit longs in a string_like fashion.
  8.     The field variable should be a long *.
  9.  
  10.     C-scape 3.1
  11.     Copyright (c) 1986, 1987, 1988 by Oakland Group, Inc.
  12.     ALL RIGHTS RESERVED.
  13.  
  14.     Revision History:
  15.     -----------------
  16.      5/12/88 jmd    added calls to sed_GetScratchPad()
  17.      9/15/88 jmd     removed vid_Cursor calls
  18.      9/17/88 jmd    added global error msg strings for easy changing
  19.      9/17/88 jmd     added std_ funcs
  20.     10/06/88 jmd    added stdBigCur_fenter
  21.     10/09/88 jmd     added SED_ABORT support
  22.     10/14/88 jdc    added var_size element to field_funcs_struct
  23.  
  24.      6/03/89 jmd    added strclip to senter func
  25. */
  26.  
  27. #include <stdio.h>
  28. #include <ctype.h>
  29. #include <string.h>
  30.  
  31. #include "cscape.h"
  32. #include "ostdlib.h"        /* for atol() */
  33.  
  34. #include "fnfunc.h"            /* for field functions */
  35. #include "strdecl.h"        /* for C-scape string functions */
  36. #include "scancode.h"
  37.  
  38. OGLOBAL field_funcs_struct slong_funcs = {
  39.     stdBigCur_fenter,
  40.     long_fexit,
  41.     sint_fkey,
  42.     slong_senter,
  43.     slong_sexit,
  44.     sizeof(long)
  45. };
  46.  
  47. void slong_senter(sed, fieldno)
  48.     sed_type sed;
  49.     int fieldno;
  50. /*
  51.     Convert the native long into the record string.
  52. */
  53. {
  54.     sprintf(sed_GetScratchPad(sed), "%ld", *((long *) sed_GetVar(sed, fieldno)));
  55.     strleft(sed_GetScratchPad(sed), sed_GetRecordLen(sed, fieldno));
  56.     strclip(sed_GetScratchPad(sed));
  57.     sed_SetRecord(sed, sed_GetScratchPad(sed), fieldno);
  58.  
  59.     std_senter(sed, fieldno);
  60. }
  61.  
  62. void slong_sexit(sed, fieldno)
  63.     sed_type sed;
  64.     int fieldno;
  65. /*
  66.     Convert the record string back into the native long.
  67.     Remove commas from string first.
  68. */
  69. {
  70.     if (sed_GetBaton(sed) != SED_ABORT) {
  71.         strcpy(sed_GetScratchPad(sed), sed_GetRecord(sed, fieldno));
  72.         strnocomma(sed_GetScratchPad(sed));
  73.         *((long *) sed_GetVar(sed, fieldno)) = atol(sed_GetScratchPad(sed));
  74.     }
  75. }
  76.  
  77.