resetting a counter daily

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf resetting a counter daily

  • Creator
    Topic
  • #51245
    Joseph Paquette
    Participant

    Hello,

       Working on a billing message that requires a counter that starts at 1 and counts up,  I can easily setup the counter and get the value into the message,  however I cannot figure out how to reset the counter on a daily basis so that at midnight each night the counter resets.  Any help would be greatly appreciated.

    Joe Paquette GE Healthcare

Viewing 3 reply threads
  • Author
    Replies
    • #69337
      David Barr
      Participant

      You could include the date in the counter name. You’d have to clean up the counter files from previous days.

      You could also check the modification time of the counter file, and if it was on a different day than today, reset the counter.

    • #69338
      James Cobane
      Participant

      Joe,

      If your using the Cloverleaf counter functions in your script (i.e. CtrNextValue, CtrCurrentValue, etc.), then you can simply set up a daily cron job to remove the .ctr file.  The next time the CtrNextValue command runs, it will simply re-create the .ctr file, thus re-initializing the counter.

      Hope this helps.

      Jim Cobane

      Henry Ford Health

    • #69339
      Joseph Paquette
      Participant

      Hello,

         Using windows,  so what i did is write a bat file to delete the counter file at midnight every night.  This seems to be working as needed,  thanks for the help.

      Joe

    • #69340
      Troy Morton
      Participant

      If you wanted to get fancy and do this automatically in the script, you could have the script write the current date to a file in your process directory on startup.  Then in the run section compare the date in the file with the current system date.  If its different, the day has changed and the counter needs to be reset.  Then after resetting the counter, write the new current date to the file.  So, every day at midnight, the same logic will detect the date changed, resent the counter and reset the new current date.

      The one con to this method is that you are reading the date value from that file for EVERY message that is processed, which could be considered unnecessary I/O.

      -Troy

Viewing 3 reply threads
  • The forum ‘Cloverleaf’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,043
Forums
28
Topics
9,200
Replies
34,021
Topic Tags
267