Newbie Questions: How to remove the leading zeros in tcl

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Newbie Questions: How to remove the leading zeros in tcl

  • Creator
    Topic
  • #50717
    Shu Chen
    Participant

    Hi guys,

    I would like to remove MRN leading zeros. sometimes there are 1 zero and sometimes there are 3 or 4.. which function should i use to to remove the leading zeros? any suggestions? thanks!!!

    PID|0001||0130447||

    PID|0001||0008537||

Viewing 3 reply threads
  • Author
    Replies
    • #67227
      Tom Rioux
      Participant

      Shu,

      The simplest would probably be the string command.   There is called “trimleft” where you can specify a character or number to trim from the left (leading) side of a variable.

      string trimleft $variable 0

      Hope this helps…Tom

    • #67228
      Shu Chen
      Participant

      trimleft is perfect for my issue. thank you so much!!!

    • #67229
      Ariba Jones
      Participant

      I need to do the exact same thing.  The problem is I don’t know from the replies where you put the command for this.  

      Can this be put in the ‘Pre’ tcl section of a COPY statement in an XLATE?  If so, how do you define the variable?

    • #67230
      Tom Rioux
      Participant

      Ariba,

      This can be done in an xlate.   You can do something like:

      set mrn [lindex $xlateInVals 0]

      set xlateOutVals [string trimleft $mrn 0]

      or simply (but I know there are those out there that don’t like this way)

      set xlateOutVals [string trimleft $xlateInVals 0]

      Hope this helps…

      Tom

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

Forum Statistics

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