join list

  • Creator
    Topic
  • #50472
    Rick Pritchett
    Participant

    I need the part of a message starting with the GT1.  What i would like to do i be able to concat this onto another message.  How would I rejoin this part of my original use for later

    set segList [split $SITE_ADT_msg r]

    set SITE_ADT_GT1_loc [lsearch -regexp $segList {^GT1}]

    echo GT1 SITE_ADT_GT1_loc $SITE_ADT_GT1_loc

    set GT1_to_end

      ]

    Viewing 5 reply threads
    • Author
      Replies
      • #66233

        Rickey, I would like to help you, but I honestly do not understand what you’re asking. Can you provide more detail, please?

        -- Max Drown (Infor)

      • #66234
        Rick Pritchett
        Participant

        I am trying to the GT1 and following segments from my original ADT and save the new joined list to a variable.  When i try to rejoin my new list using r it doesn’t seem to work.

      • #66235

        Here is some sample code that you may be able to modify to suit your needs. Naturally, there are lots of ways to do this.

        Code:


        set debug 1

        set msg  “MSH|1|2|3^MEVN|1|2|3^MPV1|1|2|3^MGT1|1|2|3^MGT1|2|3|3^MOBX|1|2|3^M”
        regsub {r$} $msg msg

        set segmentList [split $msg r]

        foreach segment $segmentList {

           if {[regexp {^GT1} $segment]} {
               lappend gt1Segments $segment
           }
        }

        if {$debug} {puts $gt1Segments}
        if {$debug} {puts [join $segmentList r]}

        -- Max Drown (Infor)

      • #66236
        Tom Rioux
        Participant

        What does the rest of your code look like?  In particular, the join command where you are putting the segments back together.

        Thanks…

        Tom Rioux

      • #66237
        John Mercogliano
        Participant

        Rickey,

         when you execute this statement:

        Code:

        set GT1_to_end [list [lrange $segList $SITE_ADT_GT1_loc end]]


        remove the list command so it looks like this:

        Code:

        set GT1_to_end [lrange $segList $SITE_ADT_GT1_loc end]

        The problem is your variable is already in a list with multiple elements and will return a list with one or more segments so you don’t need the extra list command. Your join should now work.

        John Mercogliano
        Sentara Healthcare
        Hampton Roads, VA

      • #66238
        Rick Pritchett
        Participant

        Thanks John you were right I was list happy.

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

    Forum Statistics

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