Variable Filter

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

Variable Filter

Post by francof » Sun Jul 20, 2014 4:32 pm

ciao all,
I'm filtering the content of a variable in this way

Code: Select all

 filter tTempList with  "[1-3]*"
something like: give me all the chunks starting with 1 or 2 or 3

but, if I want, for example, only those that starts with 1 or 2. how can I do without repeating the code like:

Code: Select all

 switch tNumLiv                                        
      case 3                                                      
         filter tTempList with  "[1-3]*"
         --put tNumLiv into tLivInizio
         --put tNumLiv into tLivFine
         break
      case 2                                                      
         filter tTempList with  "[1-2]*"
         --put 1 into tLivInizio
         --put tNumLiv into tLivFine
         break
etc.
......
....
tLivInizio could be the lower value, tLivFine the upper

franco

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

Re: Variable Filter

Post by francof » Sun Jul 20, 2014 5:58 pm

looking for FILTER in the dictionary:
[char-char]
Matches any character whose ASCII value is between the first character and the second character.
the value is between...

so I tried this

Code: Select all

filter tTempList with  "[ ' "& tLivInizio &" ' -  ' "& tLivFine &" ' ]*"
it's work if the character interval is 1-1 (return the lines beginning with 1)
and 1-2 (return the lines beginning with 1 and 2)
but with 1-3 (which should return the lines beginning with 1 and 2 and 3) instead return only the lines beginning with 1 and 3, without the lines 2.

where am I wrong?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Variable Filter

Post by bn » Sun Jul 20, 2014 7:02 pm

Hi Franco,

try this:

Code: Select all

put 1 into tLivinizio
   put 3 into tLivFine
   filter tTempList with  "["& tLivInizio & "-" & tLivFine &"]*"
it works for me.

Kind regards
Bernd

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

Re: Variable Filter

Post by francof » Sun Jul 20, 2014 8:00 pm

for me too!
thanks a lot Bernd, you are the number 1 (of the world)
as usual I make confusion with syntax; " ? ' [ < ' &

ciao
franco

Post Reply