TRANSLATION REORDER DATE

Homepage Clovertech Forums Cloverleaf TRANSLATION REORDER DATE

  • Creator
    Topic
  • #116248
    Stewart
    Participant

    What’s a way to reorder a string / date in a translation?

Viewing 7 reply threads
  • Author
    Replies
    • #116249
      Jim Kosloskey
      Participant

      A few ways depending on the reformatting needed and whether willing to use Tcl or not.

      How about an example of what you are attempting?

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

    • #116250
      Stewart
      Participant

      01/02/20 needs to become 20200102

    • #116251
      Jim Kosloskey
      Participant

      OK well first of all dates post 1999 are supposed to have the century so there is that to think about (is that 1920 or 2020?). You are assuming 2020 but could it be 1920?

      No Tcl (assuming you have decided all of the years are in the 20 cc and never 19):

      Use the STRING Action SUBSTRING function to extract the month portion of the date storing the result in a temp variable (let’s say @mm).

      Then use the STRING Action SUBSTRING function to extract the day portion of the date storing the result in a temp variable (let’s say @dd).

      Then use the STRING Action SUBSTRING function to extract the year portion of the date storing the result in a temp variable (let’s say @yy).

      Then CONCAT =20 with @yy placing the result in a temp variable (let’s say @ccyy).

      Then CONCAT @mm @dd @ccyy placing the result in the destination field.

      For Tcl you could do the same thing using string or regsub I would guess. Someone else would need to provide you with the regsub spec.

      Do you know how to write an xltmp type Tcl proc that interacts with the Xlate?

      Personally I would press the sending system to provide a proper date and eliminate the century concern then use the Xlate Actions outlined above but no need to CONCAT =20 with @yy just extract @ccyy from source date.

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

    • #116252
      Charlie Bursell
      Participant

      A much simpler way:

      set indt 01/02/20

      set outdt [clock format [clock scan $indt] -format %Y%m%d]

       

    • #116258
      Stewart
      Participant

      Jim,

      I don’t know how.  In the translation configurator, I see the Pre Proc / Post Proc and have attempted to use this but am having trouble.  If I need to manipulate the value of 2(0).1(0).1(0).0(0).OBX(0).#5(0) with the Tcl proc, how do I use this in the Tcl editor?

    • #116261
      Jim Kosloskey
      Participant

      Then if this needs to be done right now use the Xlate method I described. Then either take level 2 training or spend some time learning how to write Xlate (xltp) Tcl code.

      I don’t think this forum is the place for training.

       

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

    • #116268
      Charlie Bursell
      Participant

      In an Xlate pre proc, assuming the value you are passing contains the date you want to change:   Note no error checking for valid date

      As Jim said you really need some training

       

      set indt [lindex XlateInVals 0]

      set outdt [clock format [clock scan $indt] -format %Y%m%d]

      set XlateOutVals

      1. #116271
        Stewart
        Participant

        Thanks for all the help.

    Viewing 7 reply threads
    • You must be logged in to reply to this topic.

    Forum Statistics

    Registered Users
    5,129
    Forums
    28
    Topics
    9,301
    Replies
    34,448
    Topic Tags
    288
    Empty Topic Tags
    10