Post Xlate tcl

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Post Xlate tcl

  • Creator
    Topic
  • #48216
    David Harrison
    Participant

      I have a translate which concatenates a date and a time field. A post Xlate tcl code fragment should format it for output. Problem is that the output file contains the unformatted data although the correct format is displayed in the watch file.

      ######################################################################

      # Name: XltFormatDateTime

      # Purpose: Format Date & Time eg 20.12.0512:15 to 200512201215.

      #

      # UPoC type: xltp

      # Args: none

      # Notes: All data is presented through special variables.  The initial

      #   upvar in this proc provides access to the required variables.

      #

      #  This proc style only works when called from a code fragment

      #  within an XLT.

      #

      # v1  DTH 20/12/2005 Initial Version.

      proc XltFormatDateTime {} {

       upvar xlateInVals   xlateInVals

         xlateOutVals  xlateOutVals

       set x [lindex $xlateInVals 0]

       set Dtc 20

       set Dtd [string range $x 0 1]

       set Dtm [string range $x 3 4]

       set Dty [string range $x 6 7]

       set Tmh [string range $x 8 9]

       set Tmm [string range $x 11 12]

       set x $Dtc$Dty$Dtm$Dtd$Tmh$Tmm

      echo >$x<  set xlateOutVals

        }

    Viewing 3 reply threads
    • Author
      Replies
      • #58028
        Jim Kosloskey
        Participant

          David,

          Try using the proc as a Pre in the Xlate Action.

          Jim Kosloskey

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

        • #58029
          garry r fisher
          Participant

            Hi Dave,

            Is there any reason why you are using a post xlate? I tend to do all mine in pre xlates and these work fine.

            Give me a ring if you need anything.

            Regards

            Garry

          • #58030
            Dirk Engels
            Participant

              Hi David,

              the problem is that using the xlateOutVals variable in a post xlate proc won’t work. You have to put the data in the xpm handle. Try this one.

              xpmstore $xlateId [lindex $xlateOutList 0] c $x

              This should store your data in the right field on the outbound side.

              Merry x-mas from germany.

              Dirk

            • #58031
              David Harrison
              Participant

                Thanks for the suggestions. It’s now dawned on me what I was doing wrong. When I used the proc pre Xlate it was only returning the date not the time. This was because I was only taking the first value in the list. I’ve now modified it to work pre Xlate.

                ######################################################################

                # Name: XltFormatDateTime

                # Purpose: Format Date & Time eg 20.12.0512:15 to 200512201215.

                #

                # UPoC type: xltp

                # Args: none

                # Notes: All data is presented through special variables.  The initial

                #   upvar in this proc provides access to the required variables.

                #

                #  This proc style only works when called from a code fragment

                #  within an XLT.

                #

                # v1  DTH 20/12/2005 Initial Version.

                proc XltFormatDateTime {} {

                 upvar xlateInVals   xlateInVals

                   xlateOutVals  xlateOutVals

                 set x [lindex $xlateInVals 0]

                 set y [lindex $xlateInVals 1]

                 set Dtc 20

                 set Dtd [string range $x 0 1]

                 set Dtm [string range $x 3 4]

                 set Dty [string range $x 6 7]

                 set Tmh [string range $y 0 1]

                 set Tmm [string range $y 3 4]

                 set x $Dtc$Dty$Dtm$Dtd$Tmh$Tmm

                echo >$x<  set xlateOutVals

                  }

                  Merry Christmas from England,

                  Dave

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