Filter an array by content

Niggemann, Bernd Bernd.Niggemann at uni-wh.de
Fri Jun 21 05:26:27 EDT 2019


Am 21.06.2019 um 09:01 schrieb use-livecode-request at lists.runrev.com<mailto:use-livecode-request at lists.runrev.com>:

From: "J. Landman Gay"

I spoke too soon. When I tested, I hard-coded a value as the filter
string. But when I use a variable, it fails as it did before. The
elements of the array all start with a 4-character string followed by an
underscore, for example:  ER01_some text here

My variable contains "ER01":

  put tVar & "_*" into tFilter
  filter elements of sArray with tFilter into tNewArray

No go. I've tried a few different iterations. However, this works:

  filter elements of sArray with "ER01_*" into tNewArray


This works for me in 9.0.4 and 9.5 DP1

----------------------------------------------------
on mouseUp
   local tErr = "ER01"
   local tArray, tVar, tNewArray

   put (tErr & "_*") into tVar

   repeat with i = 1 to 17
      if i mod 2 is 1 then
         put tErr & "_" & i into tArray[i]
      else
         put i into tArray[i]
      end if
   end repeat
   breakpoint
   filter elements of tArray with tVar into tNewArray
   breakpoint
   filter elements of tArray with tVar
   breakpoint
end mouseUp
----------------------------------------------------

may be O <> zero?

Kind regards
Bernd





More information about the Use-livecode mailing list