From: das1191@dcsc.dla.mil (Charles M. Strickland)
Newsgroups: comp.databases,comp.lang.c
Subject: BUG TRYING TO CUSTOMIZE ENTER
Date: 5 Jan 93 19:40:08 GMT
Followup-To: comp.databases
Organization: Defense Construction Supply Center, Columbus

BELOW IS A PROGRAM TO CUSTOMIZE ENTER FOR UNIFY 4.0.
THE FIELDS AT THE BOTTOM OF THE SCREEN ARE CALCULATED FROM SUBTRACTING
VARIOUS DATES ENTERED FROM EACH OTHER.  THE CALCULACTIONS WORK FINE WHEN
ADDING A NEW RECORD, BUT AS SOON AS YOU DO CONTROL-U TO SAVE THE
RECORD TO THE DATABASE, THE NUMBERS CHANGE TO A 8 DIGIT NUMBER ON THE
SCREEN AND THE NUMBER SAVED IN THE DATABASE IS A 3 DIGIT NUMBER.
THE SCREEN FIELDS ARE DEFINED AS 3 NUMERIC
AND DEFINED IN THE DATABASE AS 3 NUMBERIC. I KNOW IT IS HARD
TO VISUALIZE WITHOUT SEEING IT HAPPEN, BUT CAN ANYONE TELL ME WHY THIS
IS HAPPENING?  I KNOW IT IS A PROBLEM WITH DATA REPRESENTATION, BUT
I DON'T KNOW HOW TO CORRECT THE PROBLEM.
IF ANYONE CAN HELP ME WITH THIS BUG, I WOULD GREATLY APPRECIATE IT.

MY NAME IS CHARLES STRICKLAND         TELEPHONE (AV) 850-2701
	   DITSO-GCIS                 email address = das1191@dcsc.dla.mil
	   COLUMBUS, OHIO

#include "/app/accell/include/edits.h"
#include "/app/accell/include/chookincl.h"
#include "/usr/include/ctype.h"
#include "/locapp/mipr/bin/itoa.c"
$include "file.h"
#include "mipree.h"
#include <time.h>
#include <stdio.h>
#include "julian.c"
#include "str_int.c"
char vstatcd[] = {" "};
/*int cksal();
int ck_ar();
int ed_date();
int ed_d1();*/
/*#include "/app/accell/include/edits.h"*/
/*#include "/usr/lib/libtermcap.a"*/
/*#include "ctype.h"*/
int ed_date();
int ed_ta();
int curdate();
int cksal1();
int cksal11();
int cksal2();
int cksal3();
int cksal4();
int cksal5();
int cksal();
int cksalfir();
int cksalall();
int cksalallp();
int ck_ars();
int ck_ar();
int blank1();
int blank2();
int blank3();
int blank4();
int blank5();
int blank6();
int blank7();
int blank8();
int blank9();
int blank10();

SFTABLE edit1[] = {
aa,0,0,blank1,
ab,0,0,blank1,
ac,0,0,blank1,
ad,0,0,blank1,
ae,0,0,blank1,
af,0,0,blank1,
ag,0,0,blank2,
ah,0,0,blank1,
ai,0,0,blank1,
aj,0,0,blank1,
b5,cksal1,0,ck_ar,
a5,cksal1,0,ck_ar,
d5,cksal1,0,ck_ar,
b2,cksal,0,ck_ars,
fincl,cksal2,0,blank3,
c5,cksal3,0,blank5,
accptdat,cksal4,0,blank4,
cd,cksalfir,0,ed_date,
tp,0,cksalallp,blank6,
ta,0,ed_ta,0,
tt,0,cksalall,blank8,
ti,0,cksalall,blank9,
tl,0,cksalall,blank10,
-1,0,0,0};

SCRTABLE screentab[] = {
"mipree",0,0,edit1,
0,0,0,0};


/*  cksal is used to skip fields - not let user change contents */ 
cksalall (sfld, buf)
int sfld;
char *buf;
{
     return (0);
}

/*  subtract received date from accept date to get timely accept */ 
ed_ta (sfld, buf, ier)
int sfld, ier;
char *buf;
{
  char xi[30];
  char xii;
  char xiii;
  char xiiii;
  double var;
  char varx;
  int conv;
  gfield (accdate,&xii);
  gfield (recdate,&xiii);
  xiiii = xii - xiii;
    outbuf (sfld,&xiiii);
    pfield (timea,&xiiii);
    return (0);
}

/*  cksal is used to skip fields - not let user change contents */ 
cksalallp (sfld, buf)
int sfld;
char *buf;
{
  short xii;
  short xiii;
  int xiiii;
  double var;
  char varx;
  gfield(awddate,&xii);
  gfield(findate,&xiii);
  xiiii = xii - xiii;
  pfield(timep,&xiiii);
     return (0);
}


/*  cksal is used to skip fields - not let user change contents */ 
cksalfir (sfld, buf)
int sfld;
char *buf;
{
     return (-3);
}



/*  cksal is used to skip fields - not let user change contents */ 
cksal (sfld, buf)
int sfld;
char *buf;
{
    char xisal[3];
    gfield(statcd,&xisal);
    if (xisal[0] == ' ')
     return (-3);
    /*else*/
     return(0);
}

/*  cksal is used to skip fields - not let user change contents */ 
cksal1 (sfld, buf)
int sfld;
char *buf;
{
    short xi;
    gfield(awddate,&xi);
   if ((xi == -32768) && (scrmode == ADD))
     return (-3);
    /*else*/
     return(0);
}

cksal11 (sfld, buf)
int sfld;
char *buf;
{
    short xi;
     return (-3);
}

/*  cksal is used to skip fields - not let user change contents */ 
cksal2 (sfld, buf)
int sfld;
char *buf;
{
    short xi;
  gfield(initdate,&xi);
   if (xi == -32768)
     return (-3);
    /*else*/
     return(0);
}

/*  cksal is used to skip fields - not let user change contents */ 
cksal3 (sfld, buf)
int sfld;
char *buf;
{
    short xi;
  gfield(accdate,&xi);
   if (xi == -32768)
     return (-3);
    /*else*/
     return(0);
}

/*  cksal is used to skip fields - not let user change contents */ 
cksal4 (sfld, buf)
int sfld;
char *buf;
{
    short xi;
  gfield(recdate,&xi);
   if (xi == -32768)
     return (-3);
    /*else*/
     return(0);
}

/* 
   the blank1,2,3 rtns are used to prevent the user from not entering data.
   the use in the work_ord screen is to ensure that something is input
   for a work description and justification - at least the 1st line
*/

blank1 ( sfld, buf, ier)
int sfld, ier;
char *buf;
{
  char xi[30];
  double var;
  char varx;
  if ((ier == -3) && (scrmode == ADD))
     return (-1);
     /*else */
     return (0);
}
    /*  
    ck_ar routine checks status code to see if it is an R. If it is, then
    the status field MUST be filled in. If statcd = A, then status field can 
    skipped.
    */

ck_ar (sfld,buf,ier)
int sfld,ier;
char *buf;
{
   short xst;
   gfield (awddate,&xst);
   if (xst == -32768)
      return (0);
  if ((ier == -3) && (scrmode == ADD))
   /*if (ier == -3)*/
      return (-1);
      /*else*/
      return (0);
}

ck_ars (sfld,buf,ier)
int sfld,ier;
char *buf;
{
    char xisal[3];
   if ((ier == -3) && (scrmode == ADD))
      return (-1);
      /*else*/
      return (0);
}



blank2 ( sfld, buf, ier)
int sfld, ier;
char *buf;
{
  char xi[30];
  char xiii[2];
  short xii;
  double var;
  char varx;
  if ((ier == -3) && (scrmode != ADD))
     return (0);
  if ((ier == -3) && (scrmode == ADD))
     return (-1);
  gfield(awddate,&xii);
   if (xii != -32768 && buf[1] != 'F')
   {
  prtmsg(1,23,"SECOND POS OF FUND TYPE MUST BE 'F' (UPPER CASE) WHEN AWARD DATE PRESENT");
  output(sfld);
  return (-1);
   }
     /*else */
     return (0);
}
blank5 ( sfld, buf, ier)
int sfld, ier;
char *buf;
{
  char xi[30];
  char xic[8];
  char xicc[8];
  char xiccc[8];
  short xii;
  short xiii;
  short xiiii;
  double var;
  char varx;
  gfield(accdate,&xic);
   if (strncmp(buf,xic,8) == 0) 
  return (0);
   if (strncmp(buf,xic,8) < 0) 
   {
  prtmsg(1,23,"AWARD DATE MUST BE GREATER THAN OR EQUAL TO ACCEPT DATE");
  output(sfld);
  return (-1);
   }
  return (0);
}
 
blank4 ( sfld, buf, ier)
int sfld, ier;
char *buf;
{
  char xi[30];
  char xic[8];
  char xicc[8];
  short xii;
  short xiii;
  int xiiii;
  int xiiiii;
  int xiiiiii;
  double var;
  char varx;
  gfield(recdate,&xic);
   if (strncmp(buf,&xic,8) < 0) 
   {
  prtmsg(1,23,"ACCEPT DATE MUST BE GREATER THAN OR EQUAL TO RECEIVED DATE");
  output(sfld);
  return (-1);
   }
  return (0);
}


blank3 ( sfld, buf, ier)
int sfld, ier;
char *buf;
{
  char xi[30];
  char xic[8];
  char xicc[8];
  char xiccc[8];
  short xii;
  short xiii;
  short xiiii;
  double var;
  char varx;
  gfield(initdate,&xic);
   if (strncmp(buf,xic,8) < 0) 
   {
  prtmsg(1,23,"FINAL CLOSE DATE MUST BE GREATER THAN OR EQUAL TO INITIAL CLOSE DATE");
  output(sfld);
  return (-1);
   }
  return (0);
}
 

/*  subtract final date from award date to get timely proc */ 
blank6 ( sfld, buf, ier)
int sfld, ier;
char *buf;
{
  char xi[30];
  short xii;
  short xiii;
  int xiiii;
  double var;
  char varx;
  gfield(awddate,&xii);
  gfield(findate,&xiii);
  xiiii = xii - xiii;
  outbuf(sfld,&xiiii);
  return(0);
}

/*  subtract received date from accept date to get timely accept */ 
blank7 ( sfld, buf, ier)
int sfld, ier;
char *buf;
{
  char xi[30];
  short xii;
  short xiii;
  int xiiii;
  double var;
  char varx;
  int conv;
  gfield(accdate,&xii);
  gfield(recdate,&xiii);
  xiiii = xii - xiii;
  outbuf(sfld,&xiiii);
  pfield(timea,&sfld);
  return(0);
}

/*  subtract accept date from award date to get timely alt */ 
blank8 ( sfld, buf, ier)
int sfld, ier;
char *buf;
{
  char xi[30];
  short xii;
  short xiii;
  int xiiii;
  double var;
  char varx;
  gfield(awddate,&xii);
  gfield(accdate,&xiii);
  xiiii = xii - xiii;
  outbuf(sfld,&xiiii);
  pfield(timealt,&xiiii);
  return(0);
}

/*  subtract accept date from issue date to get timely issue */ 
blank9 ( sfld, buf, ier)
int sfld, ier;
char *buf;
{
  char xi[5];
  short xii;
  short xiii;
  int xiiii;
  double var;
  char varx;
  gfield(issdate,&xii);
  gfield(accdate,&xiii);
  xiiii = xii - xiii;
  outbuf(sfld,&xiiii);
  if (scrmode == ADD)
  pfield(timei,&xiiii);
  return(0);
}

/*  subtract issue date from final date to get timely sol */ 
blank10 ( sfld, buf, ier)
int sfld, ier;
char *buf;
{
  char xi[30];
  short xii;
  short xiii;
  int xiiii;
  double var;
  char varx;
  gfield(findate,&xii);
  gfield(issdate,&xiii);
  xiiii = xii - xiii;
  outbuf(sfld,&xiiii);
  pfield(timesol,&xiiii);
  return(0);
}

ed_date (sfld, buf, ier)
int sfld, ier;
char *buf;
{
  short jday;
  char field[8];
    jday = curdate ();
    outbuf (sfld, &jday);
    pfield(chgdate,&jday);
    *(short *)buf = jday;
    return (0);
}

int curdate ()
{
    struct tm *ts, *localtime();
    long tloc;
    int jday, darr[3];

    time (&tloc);
    ts = localtime (&tloc);
    darr[0] = ++(ts -> tm_mon);
    darr[1] = ts -> tm_mday;
    darr[2] = ts -> tm_year;
    jday = kday (darr);
    return jday;
}
Newsgroups: comp.databases