Filter: to get unambiguous data

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
francof
Posts: 237
Joined: Fri Apr 11, 2014 10:51 am

Filter: to get unambiguous data

Post by francof » Tue Sep 09, 2014 10:10 am

Hi all,

I must filter by code row content some lines of a text field containing data like this:
cod. .name
1. . .frank
2. . .bill
....
....
10. . .mark
11. . .mary

now eg. I'm looking for the code 1

Code: Select all

put tCod & "*" into tFind
   filter tDettNomi with  tFind           
the code above return me frank but also mark and mary....
to get only frank, I thought to add a repeat loop, on the filtered lines only, to match the exact code.
or there is a better way?

thanks
franco

Klaus
Posts: 14205
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Filter: to get unambiguous data

Post by Klaus » Tue Sep 09, 2014 11:50 am

Hi Franco,

looking at your data, it looks like this might work:
...
put 1 & "." into tCod
put tCod & "*" into tFind
filter tDettNomi with tFind
...
Get to know your data! :D

Best

Klaus

francof
Posts: 237
Joined: Fri Apr 11, 2014 10:51 am

Re: Filter: to get unambiguous data

Post by francof » Tue Sep 09, 2014 1:56 pm

ciao Klaus,

sorry, my fault.
the dots, to which I think you are referring, aren't in the data.
I've used they only to show data in columns.. :oops: blank spaces do not appear on the screen....
correct data are:
1 frank
2 bill
...
...
10 mark
11 mary

best
franco

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

Re: Filter: to get unambiguous data

Post by dunbarx » Tue Sep 09, 2014 2:11 pm

Hi.

I think the problem with your earlier method was that the "1" was also acceptable as "10" or "11", since the first character was also a "1" in those lines.

Use an array. If you have your data in a field "toSplit", then in a button script:

Code: Select all

on mouseUp
   get fld "toSplit"
   split it with return and space
end mouseUp
Place a breakpoint at the "end mousUp" line. See? The array is now in place. You can store this array in a custom property. Now whenever you want a particular line, just get the array (property) and extract for line 1, or whatever.

Craig Newman

Klaus
Posts: 14205
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Filter: to get unambiguous data

Post by Klaus » Tue Sep 09, 2014 2:40 pm

Buongiorno franco,
francof wrote:ciao Klaus,

sorry, my fault.
the dots, to which I think you are referring, aren't in the data.
I've used they only to show data in columns.. :oops: blank spaces do not appear on the screen....
correct data are:
1 frank
2 bill
...
AHA! :D

OK, why not slightly modify my initial script:
...
put 1 & SPACE into tCod
put tCod & "*" into tFind
filter tDettNomi with tFind
...
8)


Best

Klaus

francof
Posts: 237
Joined: Fri Apr 11, 2014 10:51 am

Re: Filter: to get unambiguous data

Post by francof » Tue Sep 09, 2014 3:26 pm

Hi Craig,
I must study your suggestion before apply it, thanks.

Klaus,
Klaus wrote: ...
AHA! :D

OK, why not slightly modify my initial script:
...
put 1 & SPACE into tCod
put tCod & "*" into tFind
filter tDettNomi with tFind
...
8)


Best

Klaus
I fear of having repeated my mistake, below my data after filtering for code = 1:

Code: Select all

put tNumN & "*" into tFiltra
filter tDettDocDocg with  tFiltra 
Immagine.jpg
the two green lines are correct, the third, the red one, is wrong (code = 10)

if I try your exemple:

Code: Select all

put tNumN & SPACE into pippo
 put pippo & "*" into tFiltra
filter tDettDocDocg with  tFiltra 
I get an empty string.

thanks all for your time
best
franco

Klaus
Posts: 14205
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Filter: to get unambiguous data

Post by Klaus » Tue Sep 09, 2014 3:48 pm

Ciao Franco,
francof wrote:I fear of having repeated my mistake, below my data after filtering for code = 1:
true! No comment 8)

If my example does not work, then there is NO space after the numbers!
From your screenshot it looks like a TAB, so I will leave the appropriate modification of my actual script to you! :D

Sorry, but I have to say it again: GET TO KNOW YOUR DATA!


Best

Klaus

francof
Posts: 237
Joined: Fri Apr 11, 2014 10:51 am

Re: Filter: to get unambiguous data

Post by francof » Tue Sep 09, 2014 4:48 pm

Hi Klaus,
Klaus wrote: ...
If my example does not work, then there is NO space after the numbers!
From your screenshot it looks like a TAB, so I will leave the appropriate modification of my actual script to you! :D
...
TAB!, TAB! and TAB!
you don't belive me but, I swear, before my last reply i've tried tab instead of space. evidently I've wrong something else.

thank you again
best, franco

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10053
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Filter: to get unambiguous data

Post by FourthWorld » Tue Sep 09, 2014 4:51 pm

When in doubt it can sometimes be helpful to turn on the vGrid property of a field, so tabs will automatically align to the tabstops and you can spot them instantly.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

francof
Posts: 237
Joined: Fri Apr 11, 2014 10:51 am

Re: Filter: to get unambiguous data

Post by francof » Wed Sep 10, 2014 8:03 am

Hi
FourthWorld wrote:When in doubt it can sometimes be helpful to turn on the vGrid property of a field, so tabs will automatically align to the tabstops and you can spot them instantly.
good idea, thanks.

regards
franco

Post Reply