tcl help

  • Creator
    Topic
  • #51263
    Andrew Deters
    Participant

      I need to find the count of IN1 segments in a message using TCL.  Any help would be appreciated.

      Thanks,

    Viewing 3 reply threads
    • Author
      Replies
      • #69448

        Try something like this:

        Code:

        set numINI [regexp {IN1} $msg]

        -- Max Drown (Infor)

      • #69449
        Jonathan Hamilton
        Participant

          Three easy ways to do it, which would be best depends on what you need to do with the data.

          Option #1 – Full control:

             set split_data [split $data $seg_delim]

             set index 0

             set seg_index_list {}

             foreach segs $split_data {

                 if [cequal $seg [crange $segs 0 2]] {

                     lappend seg_index_list $index

                 }

                 incr index

             }

             set in1Count [llength $seg_index_list]

          Option #2 – Count plus the IN1 segment data:

             set split_data [split $data $seg_delim]

             set in1Segs [lmatch $splitData “IN1*”]

             set in1Count [llength $in1Segs]

          Option #3 – Just a count: (there may be a better regexp but this should work)

             set in1Count [regexp -all {rIN1|} $data]

        • #69450
          Andrew Deters
          Participant

            #3 did the trick…just needed to know how to get a count.

          • #69451
            Charlie Bursell
            Participant

              Why not simply:

              set count [llength [lsearch -all -inline -regexp $SEGMENTS {^IN1}]]

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