Filter Script & Patterns & Regex
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Filter Script & Patterns & Regex
I am very leery of the "hidden" property. Because hidden lines collapse the other lines, it can be very disconcerting that a field that has five lines only shows three, say. Never mind returns below the field, which are annoying enough.
The hidden property is only useful when actually viewing lines by people with eyes. That is precisely the time that extra care has to be taken so that the number of lines does not conflict with any visual measure, and especially with synchronized scrolling fields.
Craig
The hidden property is only useful when actually viewing lines by people with eyes. That is precisely the time that extra care has to be taken so that the number of lines does not conflict with any visual measure, and especially with synchronized scrolling fields.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 244
- Joined: Wed May 11, 2011 7:50 pm
- Location: Southern California
Re: Filter Script & Patterns & Regex
Thanks for the suggestion Jim.
Clarence Martin
chipsm@themartinz.com
chipsm@themartinz.com
Re: Filter Script & Patterns & Regex
While it is non destructive, Craig rightly points out there are possible 'gotchas' down the line if you need to count the lines. In this example, line 2 is set to 'hidden'.
If you went this route, and later needed to count lines, you'd have to make an allowance for the ones set to hidden, for example (psuedo code)
Just something to keep in mind.
If you went this route, and later needed to count lines, you'd have to make an allowance for the ones set to hidden, for example (psuedo code)
Code: Select all
// counting the lines
if the hidden of line x is not true then add 1 to myVar
put "the number of lines are " & myVar
Re: Filter Script & Patterns & Regex
Code: Select all
put the number of lines of fld 1
Code: Select all
put line 2 of fld 1
this is line 2
You are correct that you would need to use a repeat loop and the IF statement you provided in order to count the hidden lines.
It might be nice if these worked:
Code: Select all
put the number of hidden lines of fld 1
Code: Select all
hide line 2 of fld 1
If lines 2 and 4 were hidden this would give you a list of the hidden lines - "2,4" :
Code: Select all
function countHidden whatFld
repeat with x = 1 to the number of lines of fld whatFld
if the hidden of line x of fld whatFld is true then put x & comma after output
end repeat
delete char -1 of output
return output
end countHidden
Code: Select all
put the number of items of counthidden(1)
It would be easy to modify the above function to return an array that lists both hidden and shown lines - [hiddenLines[2,4],shownLines[1,3]]
Jim Lambert
Re: Filter Script & Patterns & Regex
I completely agree it is no great chore or difficulty to get the accurate count, as I said, just something to keep in mind if, for instance, it looked like the result you wanted and later couldn't figure out why the field returns 4 lines, and you only see 3.
You wrapped it up nicely in that function, very neat
You wrapped it up nicely in that function, very neat
Re: Filter Script & Patterns & Regex
Craig,dunbarx wrote: ↑Mon Dec 11, 2017 9:42 pmI was just trying to be cute with the "don't understand" thing.
That is not to say I understand.
But note that the filter command can be used without all that fancy regex/wildCard stuff. If you have a fid 1 with "a,b,c,d,e,f,g" and you:you get the string without the "b".Code: Select all
on mouseUp filter items of fld 1 without "b" into temp answer temp end mouseUp
One can move slowly from there, adding filter complexity piece by piece. Use the asterisk wildcard like Klaus mentioned, until you have enough confidence to try your first real regex gadget,
Then check out the "replaceText" function.
Craig
I'm trying to engage with filters at the moment and I can't tell you how helpful your post was on being able to implement a filter on an array as part of some learning that I'm undertaking at the moment.
Thanks again,
Kind regards,
Glenn