Tcl assistance

  • Creator
  • #52155
    Shaun Beckman

    We are working with a GL Issues file. We need to strip the leading zero from ZJD3, then compare the first 4 numbers against a list provide. If those first 4 numbers match any number in the list, then we replace them with the numbers in the list, and concatonate the remaining 4 numbers to the new number.


    Portion of file:


    ZJD||D|016123500|EXPENDABLE SUPPLIES||||||””^””||


    ZJD||D|016124600|OFFICE SUPPLIES||||||””^””||

    ZJD||D|017373600|MEDICAL SURGICAL SUPPLIES||||||””^””||

    Numbers to search for – Numbers to replace if there is a match

    1611                                        6000

    1116                                        8000

    1737                                        9000

    So in the first ZJD line above we strip the leading zero, there is a match on ‘1611’, so we replace 1611 with 6000 and concatonate that to the last four numbers ‘3550’. The result will look like:  60003550.

    Does anyone have a script they are using that will do something like this, or is there someone that could offer some suggestions.

    We are running Cloverleaf 5.8 on a Linux platform.

    Any help is greatly appreciated.

Viewing 4 reply threads
  • Author
    • #73243
      Robert Kersemakers

      I would always use a table for this; the numbers to be replaced will grow, even if everyone tells you they won’t.

      You would have something like this. I assume the table will be called ‘Table.tbl’ and will have a default of ‘XXXnoneXXX’ to mark that a number couldn’t be found and the original number is used. And I assume the zeroes are removed from the numbers in the table.


      lassign $xlateInVals field
      set first [string trimleft [string range $field 0 4] 0]
      set last [string range $field 5 end]
      set result [hcitbllookup Table.tbl $first]
      if {[string equal $result XXXnoneXXX””]} {
       set xlateOutVals [list $field]
      } else {
       set xlateOutVals [list “${result}${last}”]

      Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

    • #73244
      Shaun Beckman

      Thanks Robert.

      I’ll give this a try.

    • #73245
      Shaun Beckman


      It is real close. It works if the search value is found, but if it is not found, it is only copying the last 4 digits, when I need the entire original number without the leading zero.

      I’ll keep working on it.

      Thnanks again.

    • #73246
      Robert Kersemakers

      Ok. You need to enter the default value of the table and fill it with ‘XXXnoneXXX’. It’s at the bottom of the screen of the Lookup Table Configurator.

      This way you should get the original number returned if it can’t be found in the table. Including leading zeroes.

      You want to try to remove the leading zeroes yourself?

      Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

    • #73247
      Shaun Beckman


      With the information you provided, and a little tweaking on my part, it is working perfectly.

      Thank you very much for you help!!!

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

Forum Statistics

Registered Users
Topic Tags