Sequential Number / Global Variable

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Sequential Number / Global Variable

  • Creator
    Topic
  • #53446
    Jon Melin
    Participant

    Hello all,

    I can’t figure out a way of doing this. I am trying to create a sequential number to place in a certain segment. I need this number to be unique each time (so it has to remember the number it used in the last message).

    I was thinking of some sort of global variable that Cloverleaf could keep track of and use, but I can’t seem to find anything on it. I am just looking to have a number count up each time, without ever repeating.

    Please let me know if you are aware of anything and thank you in advance.

Viewing 10 reply threads
  • Author
    Replies
    • #77722
      Chris Williams
      Participant

      Jon,

      If you want this value to survive shutdowns of various types, it needs to be disk-based rather than held in memory with a global. Check out the followoing tcl commands:

    • CtrCurrentValue

      CtrInitCounter

      CtrNextValue

      CtrResetValue

    • Chris

  • #77723
    Jim Kosloskey
    Participant

    Jon,

    We use the counter file function provided with Cloverleaf.

    In Help under Refernce/Tcl Extensions/Counter Commands and Counter Extensions you will find documentation.

    email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

  • #77724
    Gary Atkinson
    Participant

    Like those guys said  ðŸ˜† Great thing to use if you need your MSH id number to be unique.

  • #77725
    Russ Ross
    Participant

    I have an old clovertech post showing the use of the counter file technique previously mentioned by others

    Look at my proc called

        tps_fileset_outbound

    at this URL

        <a href="http://clovertech.infor.com/viewtopic.php?t=1663&#8243; class=”bbcode_url”>http://clovertech.infor.com/viewtopic.php?t=1663

    to see a tangible example of using the counter file technique then adapt to your needs if you like.

    Russ Ross
    RussRoss318@gmail.com

  • #77726
    Jon Melin
    Participant

    Is it possible to make these calls within the TCL section of the XLATE or do I have to code it outside of the XLATE and call it?

    Do I just give it the path to the file and use the retrieve and increment variation? I am new to the external file calls.  

    Thank you

  • #77727
    Gary Atkinson
    Participant

    if you going to use in the xlate, you can set up your own counter in the translation tool.  Then use MATH or whatever to change number.

    I am not sure if you can access a .ctr file from inside a the translation..never tried that.

  • #77728
    Jon Melin
    Participant

    Can I set up a number that is being counted up from within the translation tool that will persist? I need it to always remember the last number that was used. I was hoping to try to do it from within the XLATE TCL section.

    Thank you

  • #77729
    Gary Atkinson
    Participant

    the variable you use as the counter in the translation will reset.  try using global variable instead.

  • #77730
    Jim Kosloskey
    Participant

    Jon,

    I have a proc you can call inside an Xlate – just pass it parameters.

    If you want it along with user doc – email me – my email is part of my profile

    email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

  • #77731
    Chris Williams
    Participant

    Jon,

    You’re trying to make this more complicated than it really is. You can use the Ctr* calls anywhere in the Xlate where you can use Tcl. The counter value is held on disk. If you don’t ever want the value to reset, then give it an impossibly large rollover value when you initialize it.

  • #77732
    Tom Rioux
    Participant

    Jon,

    I echo what Chris is saying.   Also, if you want your counter to start at a specific number, you can specify that when you initialize it.   You don’t have to start at 1, that is just the default.

    Hope this helps….

    Tom Rioux

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

    Forums

    Forum Statistics

    Registered Users
    5,119
    Forums
    28
    Topics
    9,293
    Replies
    34,435
    Topic Tags
    286
    Empty Topic Tags
    10