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

  1. /*
  2.     fnlong.c       10/30/86
  3.  
  4.     % long_funcs
  5.  
  6.     Long editting functions.
  7.     Variable should be a long*.
  8.  
  9.     C-scape 3.1
  10.     Copyright (c) 1986, 1987, 1988 by Oakland Group, Inc.
  11.     ALL RIGHTS RESERVED.
  12.  
  13.     Revision History:
  14.     -----------------
  15.     10/01/87 jmd     added casting
  16.      5/12/88 jmd    added calls to sed_GetScratchPad()
  17.      9/17/88 jmd    added global error msg strings for easy changing
  18.      9/17/88 jmd     added std_ funcs
  19.     10/09/88 jmd     added SED_ABORT support
  20.     10/14/88 jdc    added var_size element to field_funcs_struct
  21. */
  22.  
  23. #include <stdio.h>
  24. #include <ctype.h>
  25.  
  26. #include "cscape.h"
  27. #include "fnfunc.h"            /* for field functions */
  28. #include "strdecl.h"        /* for C-scape string functions */
  29. #include "scancode.h"
  30.  
  31. OGLOBAL field_funcs_struct long_funcs = {
  32.     num_fenter,
  33.     long_fexit,
  34.     num_fkey,
  35.     long_senter,
  36.     long_sexit,
  37.     sizeof(long)
  38. };
  39.  
  40. boolean long_fexit(sed)
  41.     sed_type sed;
  42. /*
  43.     Validates a long using the string in field data 1.
  44. */
  45. {
  46.     long val;
  47.  
  48.     if (sed_GetBaton(sed) != SED_ABORT) {
  49.  
  50.         sscanf(sed_GetCurrRecord(sed), "%ld", &val);
  51.  
  52.         /* call standard numeric validation routine (fnstdval.c) */
  53.         if (!std_NumValid(sed, (double) val)) {
  54.             return(FALSE);
  55.         }
  56.     }
  57.  
  58.     return(std_fexit(sed));
  59. }
  60.  
  61. void long_senter(sed, fieldno)
  62.     sed_type sed;
  63.     int fieldno;
  64. /*
  65.     Convert native type to string for record.
  66. */
  67. {
  68.     sprintf(sed_GetScratchPad(sed), "%ld", *((long *) sed_GetVar(sed, fieldno)));
  69.  
  70.     strright(sed_GetScratchPad(sed), sed_GetRecordLen(sed, fieldno));
  71.     sed_SetRecord(sed, sed_GetScratchPad(sed), fieldno);
  72.  
  73.     std_senter(sed, fieldno);
  74. }
  75.  
  76. void long_sexit(sed, fieldno)
  77.     sed_type sed;
  78.     int fieldno;
  79. /*
  80.     Converts record back to native type.
  81. */
  82. {
  83.     if (sed_GetBaton(sed) != SED_ABORT) {
  84.         sscanf(sed_GetRecord(sed, fieldno), "%ld", (long *) sed_GetVar(sed, fieldno));
  85.     }
  86. }
  87.