XLT Pre Proc arguments

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf XLT Pre Proc arguments

  • Creator
    Topic
  • #50383
    Corry Macfarlane
    Participant

    Ok, this is acomplete newbee question.  I’ve searched the online docs and haven’t found a good explination of how to do this so I thought I’d swallow my pride and ask the simple question here…..

    I’m doing copy translation of a date value.  I need to reformat the value before writing it out on the other side.  I’m using the following TCL proc to do the reformatting (if there’s a better way than using TCL I’d be happy to do it – and I’m not a TCL expert so there’s probably a better way to write the code but this seems to work  ðŸ™‚ )

    proc  bsc_ge_dateformat {indate} {

     set scantime [clock scan $indate -format {%Y%m%d}]

     set outdate [clock format $scantime -format {%d %b %Y}]

     return $outdate

    }

    So you can see it’s not very complicated. I assumed I would use a Pre Proc on the Copy commnad to manipulate the incoming data before writing it to the outgoing message.  What I don’t understand is how to pass the date value (eg, 1(0).1(%g1).1(%s1).OBX(0).#5(0)) into the proc so it can be written to the output value (eg, 1(0).1(%g1).1(%s1).OBX(0).#5(0)) in the outgoing message.

    Thanks

    Corry

Viewing 2 reply threads
  • Author
    Replies
    • #65912
      Charlie Bursell
      Participant

      I find it hard to believe this works.  You cannot pass a -format flag to the clock scan command.

      First of all this is an xlt proc and must be coded as such.  I assume you are getting a date in of the format 20081014 and want to format it to something like: 14 Oct 2008.

      First look at the template for an xlt proc

      proc bsc_ge_dateformat {} {

         upvar xlateId       xlateId        

               xlateInList   xlateInList    

               xlateInTypes  xlateInTypes    

               xlateInVals   xlateInVals    

               xlateOutList  xlateOutList    

               xlateOutTypes xlateOutTypes  

               xlateOutVals  xlateOutVals

          # Get the input date

           set indate [lindex $xlateInVals 0]

           # Reformat it

           set outdate [clock format [clock scan $indate] -format {%d %b %Y}]

            # Store it to outbound

            set xlateOutVals

        }

        Of course if your input date also includes HHMMSS you need to do something different to make it scanable

    • #65913
      Corry Macfarlane
      Participant

      Thanks for the template.  I knew I was missing something that I just hadn’t run across yet.  I’ll give this a try…

      According to the TCL 8.5 man pages at http://ftp.tcl.tk/man/tcl8.5/TclCmd/clock.htm#M10  clock scan can have a -format option as well as other options.  However, that doesn’t mean that Cloverleaf is using TCL 8.5 🙂  I was using tcl 8.5 to create the proc first then tried moving it to Cloverleaf.

      Thanks again!!

      Corry

      Charlie Bursell wrote:

      I find it hard to believe this works.

    • #65914
      Corry Macfarlane
      Participant

      Of course this won’t surprise you, Charlie, but it worked like a charm!

      Thanks for the quick response and some additional training info for me.

      Corry

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

Forum Statistics

Registered Users
5,043
Forums
28
Topics
9,200
Replies
34,021
Topic Tags
267