Argument From TCL Proc in Xlate

Homepage Clovertech Forums Cloverleaf Argument From TCL Proc in Xlate

Tagged: , ,

  • Creator
    Topic
  • #119388
    Jerry Magrann
    Participant

    CL 19.1.1 – For an Xlate, I was provided a TCL proc to get the last day / date of the month to copy to a field. The date is coming in as 2021-12-31T00:00:00, I need to format to yyyymmdd using the Args and not Clock Format. There are arguments in the script to use that I don’t know where / how to apply in the Xlate Copy, looking for guidance there:
    ;# Argument required by the proc are:
    ;# 1. DateInSeconds: Input Date, Optional argument. Default current date.
    ;# 2. InDateFormat: Format of input date, Optional argument. Default ‘yyyymmdd’ i.e in TCL %Y%m%d
    ;# 3. OutDateFormat: Format of output date, Optional argument. Default ‘yyyymmdd’ i.e in TCL %Y%m%d

    ac_Puts “i” “<<PROC acXlte_GetLastDateOfMonth>> args: $args xlateInVals: $xlateInVals” $xlateId
    set dateInSeconds [lindex $xlateInVals 0]
    set inDateFormat [lindex $xlateInVals 1]
    set outDateFormat [lindex $xlateInVals 2]

    Attachments:
    You must be logged in to view attached files.
Viewing 6 reply threads
  • Author
    Replies
    • #119391
      Jim Kosloskey
      Participant

      The arguments need to be in the Xlate Action Source Panel (xlateInVals).

      You can check the Tcl Date Format options to see if there is a format that matches your data.

      OR using the STRING Action to extract just the date portion to match the default.

      So…

      Source Panel
      <date>
      <ib date format or nothing for default>
      <ob date format>

      I am assuming the proc is smart enough to recognize missing args.

      If you want the default formats for ib and ob data then Source Panel would just have a properly formatted date.

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

    • #119392
      Jerry Magrann
      Participant

      Thanks Jim – I’m still having a block on how to enter the args in the source. if the args in the Proc are:
      set dateInSeconds [lindex $xlateInVals 0]
      set inDateFormat [lindex $xlateInVals 1]
      set outDateFormat [lindex $xlateInVals 2]

      My source would be:
      @date
      arg?
      arg?

      and then it hits the Proc to get the last day of the month?

    • #119393
      Jim Kosloskey
      Participant

      Your interpretation of argument placement is as I understand it should be.

      The proc then is getting the arguments via the lindex commands.

      As to the proc returning end of month date, I cannot comment as I do not have the proc to determine if that is its function.

      • This reply was modified 2 years, 10 months ago by Jim Kosloskey.

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

    • #119396
      Jerry Magrann
      Participant

      Here is the Proc, I’m not sure how to call the Args from it in the source:

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

      ac_Puts “i” “<<PROC acXlte_GetLastDateOfMonth>> args: $args xlateInVals: $xlateInVals” $xlateId
      set dateInSeconds [lindex $xlateInVals 0]
      set inDateFormat [lindex $xlateInVals 1]
      set outDateFormat [lindex $xlateInVals 2]

      set lastDateOfMonth [ac_GetLastDateOfMonth $dateInSeconds $inDateFormat $outDateFormat]
      ac_Puts “i” “lastDateOfMonth: $lastDateOfMonth”
      set xlateOutVals “{$lastDateOfMonth}”
      ac_Puts “i” “xlateOutVals: $xlateOutVals” $xlateId
      }

      • This reply was modified 2 years, 10 months ago by Jerry Magrann.
    • #119398
      Jim Kosloskey
      Participant

      It looks like this proc invokes another proc which by name appears to get last day of month. Just give it a try and see what happens.

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

    • #119400
      Charlie Bursell
      Participant

      Looks like you are over complicating things to me unless I am not understanding the problem
      Assume input is lke: 2021-12-31T00:00:00

      In the preproc of the xlate put the following:

      set dt [string map [string range [lindex $xlateInVal 0] 0 9]

        ]
        set xlateOutVals ]list $dt] ;# should yield 20211231

        You can separate out into multiple command if you like.

      1. #119407
        Jerry Magrann
        Participant

        Jim and Charlie – as always thanks for your responses and suggestions! So coming back the next day with a clearer head and not overcomplicating it, in the screen shot is what I needed to get this working:
        – in the source I used the MSH.7 for the message date time and set the format
        – in the PreProc is the TCL proc that takes the Source date and changes it to the last day of the month and the copied into the destination field.

        • This reply was modified 2 years, 10 months ago by Jerry Magrann.
        Attachments:
        You must be logged in to view attached files.
    Viewing 6 reply threads
    • You must be logged in to reply to this topic.

    Forum Statistics

    Registered Users
    5,126
    Forums
    28
    Topics
    9,296
    Replies
    34,439
    Topic Tags
    287
    Empty Topic Tags
    10