1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 <2019> 2020 2021 2022 2023 2024 2025 | Index | 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 <2019> 2020 2021 2022 2023 2024 2025 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: Count record that resets by date |
From: | Daniel Cuneo via Tech-talk <[email protected]> |
To: | Eric Norum <[email protected]> |
Cc: | "[email protected]" <[email protected]> |
Date: | Thu, 14 Mar 2019 14:30:37 -0700 |
I think that the code you show below won’t quite work right. It will increment the count once per second.Note the OOPT field in my example. It pushes the value into the count record (and hence causes the ‘count’ record to process) only when the calculation is non-zero — i.e. only when the count record is to be cleared.On Mar 14, 2019, at 11:32 AM, Daniel Cuneo via Tech-talk <[email protected]> wrote:This is what I've decided on based on Eric's and Diego's examples:I learned a lot from this. Many thanks to everyone for sharing their ideas.One gotacha: The STRINGIN record translates the time stamp to a strftime conversion, %M for testing and %j for production. That output is still a string, "001" through "365". However, CALC takes this string and casts it into an integer. I haven't confirmed this assumed cast from base source code yet, so correct me if I'm wrong.>cat db/counter.dbrecord(bi, "$(user):now") {field(PINI, "YES")field(SCAN, "1 second")field(FLNK, "$(user):day")}record(stringin, "$(user):day") {field(DTYP, "Soft Timestamp")field(INP, "@%M") # for testing purposes using 1 minutefield(TSEL, "$(user):now.TIME")field(FLNK, "$(user):clear")}record(calcout, "$(user):clear") {field(INPA, "$(user):day NPP MS")field(INPB, "1000")field(CALC, "A>B?1:0;B:=A")field(DOPT, "Use CALC")field(OOPT, "Every Time")field(OUT, "$(user):count.C PP")}record(calc, "$(user):count") {field(INPC, "$(user):clear.VAL")field(VAL, "0")#field(TPRO, 1)field(CALC, "C?0:VAL+1")}--
Eric Norum
[email protected]