TCL lsearch with -all option

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf TCL lsearch with -all option

  • Creator
    Topic
  • #48039
    Barry Sheesley
    Participant

      I am trying to search a list of segments and return the indices of all the AL1 segments in my message.  I tried the following (and several variations) of the command but I keep getting an error message.  I’m sure I just have the syntax wrong but I haven’t been able to figure it out.  

      Command: set al1Locs [lsearch -regexp -all $segments {^AL1}]

      Error Message:  wrong # args: should be “lsearch ?mode? list pattern”

      [/code]

    Viewing 3 reply threads
    • Author
      Replies
      • #57426
        Ed Mastascusa
        Participant

          all isn’t an allowable mode in lsearch

          tcl>lsearch -all

        • 3

          Error: bad search mode “-all”: must be -exact, -glob, or -regexp

          it might be easier to iterate through the list, do your AL1 check on each element and build the index list yourself – lsearch is only going to return the first element.

    • #57427
      Jim Kosloskey
      Participant

        Barry,

        Have you looked at lmatch (which returns a list of matching entries) or lregexp?

        In any case, I think Ed is correct in that the lsearch (and lmatch I believe) does not accept a -all switch.

        Jim Kosloskey

        email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

      • #57428
        Barry Sheesley
        Participant

          When I looked at the syntax of lsearch on the internet, it shows the -all option but when I looked at the Help text in TCL on my Quovadx server, it does not show the -all option.  In any case, I reworked the code to iterate through the AL1 segments as you suggested and it is working fine now.  Thanks for the responses!

        • #57429
          Jim Kosloskey
          Participant

            Barry,

            What you found on the Internet was probably for a newer release of Tcl.

            I always use the help with hcitcl as Cloverleaf does not always have the latest Tcl.

            Jim Kosloskey

            email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

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