New(ish) option on the filter command
Alex Tweedly
alex at tweedly.net
Sat Jul 16 19:10:18 EDT 2016
On 16/07/2016 00:22, [-hh] wrote:
> Usually one would do
> put cr & resultOfFilter2 after resultOfFilter1
Well, that depends ... if the first one had produced no matches, then
this statement would introduce a spurious blank line.
> So the problem could be:
>
> What should "filter .. after tVar" exactly do?
It should simply concatenate. Just like
put myVar after myOtherVar
does.
If I had done it the old-fashioned way, like
filter t with "*.jpg" into t1
filter t with "*.jpeg" into t2
put t1 & CR & t2 into myFinalVar
then I would have needed to know that files(), and filter, both omit the
final CR, and deal with it accordingly.
So there's no reason for "filter ... after myVar" to try to be any
cleverer than "put ... after myVar"
> Simply concatenate?
> Or use the current linedelimiter as "connector"?
-- Alex.
P.S. I could, of course, revive my old rant about the need for *proper*
lists in LC Script, rather than always mimicking them as lines where we
need to deal with trailing, or intermediate, delimiters, etc. Then we
could avoid complexities like
function concatenateLines p1, p2
put p1 into tResult
if p1 is not empty AND p2 is not empty AND the last char of p1 <> CR
then put CR after tResult
put p2 after tResult
return tResult
end concatenateLines
>
> Alex Tweedly wrote
>> OK, so it's not that new - it was added in 6.1 :-)
>>
>> filter now allows you to specify a "target container", e.g.
>>
>> filter myVar with "*.livecode" into tStacks
>>
>>
>> Would it be a reasonable enhancement request to allow not just "into",
>> but also "after" and "before" ?
>>
>> e.g.
>>
>> put files() into t
>>
>> filter t with "*.jpg" into tFiles
>>
>> filter t with "*.jpeg" after tFiles
>>
>> etc.
>>
>> btw - if you are hopeful and just try the "after variant", it doesn't
>> give you an error - it simply ignores the "after targetContainer" part,
>> and filters the source container. Seems to me that's a bug - anyone
>> agree and I'll enter it as such ?
>>
>> -- Alex.
>>
>>
>>
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at .runrev
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
>
>
> --
> View this message in context: http://runtime-revolution.278305.n4.nabble.com/New-ish-option-on-the-filter-command-tp4706763p4706765.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list