Xlate Proc Issues with Clock Format

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Xlate Proc Issues with Clock Format

  • Creator
    Topic
  • #53991
    Danny Wheeler
    Participant

      I am trying to write a Xlate file that brings in a VRL and outputs an HL7 message.  I have most of it working except for a piece of data I need to format.  In that field a date like “1/1/2013 12:00 AM” is coming in and I need to change it to “20130101” without the time piece.  I really don’t understand why this bit of code is not working.  In the testing tool I get an error “Expected integer but got “1/1/2013”  What am I doing wrong?

      Code:


      set var [lindex $xlateInVals 0]
      set part [string range $var 0 [expr {[string first ” ” $var] -1 }]]
      set xlateOutVals [clock format $part -format %Y%m%d]

      Thank you.

    Viewing 3 reply threads
    • Author
      Replies
      • #79789
        bill bearden
        Participant

          Try this as your 3rd line.

          Code:

          set xlateOutVals [clock format [clock scan $part] -format %Y%m%d]

        • #79790
          Danny Wheeler
          Participant

            Thank you so much!  That worked great.  Can you help me understand why that worked?  My understanding is that all variables in TCL are strings so I am not sure why it had this issue.  Sorry if I am way off base I am relatively new to Integration/Cloverleaf.

          • #79791
            Terry Kellum
            Participant

              Clock scan interprets a textual date/time into a number of seconds since “The Epoch”.  Clock format takes that number and turns it into a textual date and time, formatted like the specification you give it.

              clock scan can be tricky, so make sure you test thoroughly.

            • #79792
              Jim Kosloskey
              Participant

                Also,

                Get used to treating the xlateInxxx and xlateOutxxx lists as lists.

                You did so in getting xlateOutVals but you did not in setting xlateOutVals.

                While as long as your format does not contain any spaces in it you won’t have issues to make sure use something like the list or lreplace command to make sure what you are giving xlateOutVals is a list (even if it is a list of a single element).

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

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