#	Copyright 1990, Performance Systems International Inc.
#	Copyright 1988,1989 NYSERNet, Inc.
#	Copyright 1990, Sony Corp.
#	All Rights Reserved.
/VARIABLE/{
  # the manipulations below are to calculate the number of hours since
  # 00:00:00 Jan 1 1985. The calculations don't take into account leap
  # years etc., but we're concerned with differences in time, not
  # absolute time, so it doesn't matter

  split($DateO,date," ");		# split the date up
  tstr	= date[DTime];
  split(date[DTime],tm,":");		# split up hh:mm:ss time
  hr = sprintf("%d", tm[THour]);
  min = sprintf("%d", tm[TMin]);
  period  = (hr * 4) + min / 15;	# period since beginning of the day

  # Having got the time, now calculate difference

  if(last[VARNAME] != 0)		# if this is not the first time
  {
    dif		= $ValO - val[VARNAME];		# get the difference
    delta	= period - last[VARNAME];

    if(dif > 0 && delta >= .8 && delta <= 1.2)		#   counter was reset
    {
      printf "VARIABLE\t%d\t%d\n", period, dif;
    }
  }
  val[VARNAME]	= $ValO;		# save old value
  last[VARNAME]	= period;
}
