Replacing null fields

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Replacing null fields

Viewing 2 reply threads
  • Author
    Replies
    • #70878
      Tom Rioux
      Participant

        David,

        The string map is apparently leaving a couple of fields blank.  This way is a bit more cumbersome, but you can try this:

        set lst “GT098193,,DM11191700,SURNAME,Forename,20011217,M,,,,,,PP”

        set lst [split $lst ,]

        set idxs [lsearch -all $lst “”]

        foreach idx $idxs {

           set lst [lreplace $lst $idx $idx “”]

        }

        set newlst [join $lst ,]

        I’m sure someone has a smoother way of doing it but I hope this helps.

        Tom Rioux

      • #70879
        Chris Williams
        Participant

          String map will match the first occurrence of ,, and make the change. The next match begins with the first set commas AFTER the previous match. It does not back up and reinterpret the comma ending the first match. “,,,,” is seen as two sets of commas, not three. That’s why you’re having to make two passes.

          Cheers.

        • #70880
          David Harrison
          Participant

            I was thinking along the lines of Chris’s logic. I think it would be less long winded to just make another pass using string replace.

            Many thanks for your suggestions,

            Dave

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