filter command limitation?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10440
Joined: Wed May 06, 2009 2:28 pm

filter command limitation?

Post by dunbarx » Tue Dec 02, 2025 10:35 pm

The "Filter" command is compact and powerful. But it is limited in the sense that it only works with "whole" lines, items, keys, etc. In other words, I wish that, given in a field 1:
aa,bb,cc
dd,ee,ff
gg,hh,jj
it would filter out line 2 from the following:

Code: Select all

on mouseUp
   get fld 1
   filter lines of it without "ee"
end mouseUp 
But it does not, since it only sees "whole" lines. Am i missing something here? Is there a way to lose line 2 because it contains a string, as opposed to the line being the string?

Craig

SparkOut
Posts: 2977
Joined: Sun Sep 23, 2007 4:58 pm

Re: filter command limitation?

Post by SparkOut » Tue Dec 02, 2025 10:41 pm

Hi Craig,
You can use * as a wildcard before/after the filter part. With some possible fudging for beginning/ends of the line and checking for CR as well.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10289
Joined: Fri Feb 19, 2010 10:17 am

Re: filter command limitation?

Post by richmond62 » Wed Dec 10, 2025 3:28 pm

I have a feeling there is a relatively straight forward way to do this.

Currently making Kichiri (marvellous stuff) in the kitchen: will get to the computer in about 30 mins and try out my idea.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10289
Joined: Fri Feb 19, 2010 10:17 am

Re: filter command limitation?

Post by richmond62 » Wed Dec 10, 2025 3:54 pm

SS 2025-12-10 at 16.51.05.png
-

Code: Select all

on mouseUp
   put empty into fld "f2"
   put 1 into LYNE
   repeat until line LYNE of fld "f1" is empty
      if line LYNE of fld "f1" contains "ee" then
         -- do nothing
      else
         put line LYNE of fld "f1" & cr after fld "f2"
      end if
      add 1 to LYNE
   end repeat
end mouseUp
-
filterTips.jpg
Attachments
filter tips.livecode.zip
Stack
(1.14 KiB) Downloaded 11 times

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10440
Joined: Wed May 06, 2009 2:28 pm

Re: filter command limitation?

Post by dunbarx » Wed Dec 10, 2025 4:05 pm

Sparkout.

Oooh. I will try that, and I realize I have done that sort of thing before. :oops: I think the fact that I am filtering by lines obviates the need to worry about returns or anything else. LC will consider only lines.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10440
Joined: Wed May 06, 2009 2:28 pm

Re: filter command limitation?

Post by dunbarx » Wed Dec 10, 2025 4:39 pm

Sparkout.

That did the trick, of course. I cannot see any traps where too much filtering might occur. Your idea is already, as I thought, restricted line by line by LC itself, and it reads to me that any line containing any string would be deleted.

Thank you. :D

Craig

Post Reply