Create Unique MSH-10

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Create Unique MSH-10

  • Creator
    Topic
  • #54974
    Edward Hafner
    Participant

      I’m getting back into working w/ Cloverleaf after a more than a year.  I seem to remember a quick way to generate a unique Message Control ID using @now directly in the XLate.  Unfortunately, I do not have access to any of the Xlates I worked with in the past.

      I know @now may not always be unique.  There was a simple tcl command to append something to it.

      Does anyone have examples of a best practice for this?

    Viewing 1 reply thread
    • Author
      Replies
      • #83642
        G Terpstra
        Participant

          We have some gen procs installed and one of them is called

          gc_generateUniqueId.

          Code:


          proc gc_generateUniqueId { args } {
             upvar xlateId       xlateId    
               xlateInList   xlateInList    
               xlateInTypes  xlateInTypes    
               xlateInVals   xlateInVals    
               xlateOutList  xlateOutList    
               xlateOutTypes xlateOutTypes    
               xlateOutVals  xlateOutVals

             set module [lindex [info level 0] 0]
             set debug     “0”
             set maxlength “-1”
             catch {
                 keylget args DEBUG     debug
                 keylget args MAXLENGTH maxlength
             }

             set uid [expr [getclock] + rand()]     ; # e.g. 1128686054.99
             if { [info exists xlateInVals] } {
                foreach el $xlateInVals { append uid “/$el” }
             }

             if { [ctype digit $maxlength] && $maxlength > 0 && [clength $uid] > $maxlength } {
                 set uid “[string range $uid 0 [expr $maxlength – 1]]”
             }

             if { $debug } { puts stdout “$module (debug): Generated unique id of [string length $uid] chars ‘$uid'” }

             set xlateOutVals [list $uid]
          }

        • #83643
          Edward Hafner
          Participant

            Thanks for the help G!

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