Inline Tcl with Xlate Copy

Clovertech Forums Cloverleaf Inline Tcl with Xlate Copy

  • Creator
    Topic
  • #122490
    Rich Brant
    Participant

      I’m using a Copy in an xlate, and want to make 20260504 look like 2026-05-04

      I’ve tried $inval, $invar, and $var.

      [string range $inval 3]-[string range $inval 4 5]-[string range $inval 6 7]

      Version 20.1, and getting an error:

      ESSAGE 1
      Tcl callout error

      [string range $inval 3]-[string range $inval 4 5]-[string range $inval 6 7]
      :

      errorCode: TCL LOOKUP VARNAME inval

      errorInfo:
      can’t read “inval”: no such variable
      while executing
      “string range $inval 3”
      invoked from within
      “[string range $inval 3]-[string range $inval 4 5]-[string range $inval 6 7]”
      <End of errorInfo>

    Viewing 1 reply thread
    • Author
      Replies
      • #122491
        Jason Russell
        Participant

          The variable you’re looking for is xlateInVals which is a list. If you are 100% certain you will always pass in a 8 digit date, you can use TCL’s clock command:

          set xlateOutVals [ list [clock format [clock scan [lindex $xlateInVals 0] -format %Y%m%d\] -format “%Y-%m-%d”\]\]

          From the inside out:

          lindex gets the first item of the list passed in via xlateInVals

          Clock scan will scan that in the format given (YYYYMMDD)

          Clock format will format that scanned time in the format given (YYYY-MM-DD)

          List recreates the list for xlateOutVals.

        • #122495
          Jason Russell
          Participant

            I edited too many times (the bbcode was trying to format the list command). here’s the code without the slashes:

            set xlateOutVals [ list [clock format [clock scan [lindex $xlateInVals 0] -format %Y%m%d] -format ā€œ%Y-%m-%dā€]]

            • #122496
              Rich Brant
              Participant

                Does pre/post matter in that scenario?

              • #122497
                Jim Kosloskey
                Participant

                  Yes, you want pre.

                  email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 61 years IT – old fart.

            Viewing 1 reply thread
            • You must be logged in to reply to this topic.