Find with * & string

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

Find with * & string

Post by francof » Sat Oct 25, 2014 6:10 pm

Hi all,

I have 2 list fields:
fldTblAbbinamenti containing 2 colums of data: row1 FOODS, row2 WINES, and
fldVini containing WINES.

with this code:

Code: Select all

on mouseup
   local tVinoDaAbbinare, tAbbinamenti
   
   set itemdel to TAB
   
   put fld "fldTblAbbinamenti" into tAbbinamenti
   put "*" & the selectedText of me into tVinoDaAbbinare
   
   filter tAbbinamenti with tVinoDaAbbinare
end mouseup
I try to show only that lines containing the selected wine in field fldVini .
do not work it returns empty.

but, for exemple, if I select the wine "Carema" from field fldVini and replace the variable of the line of code
"filter tAbbinamenti with tVinoDaAbbinare" with
"filter tAbbinamenti with "*Carema"
it's work, returns me the corrects lines

What I'm wrong?
best
franco

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

Re: Find with * & string

Post by Klaus » Sat Oct 25, 2014 6:39 pm

Hi Franco,

your FILTER will only leave lines that END with your searchstring, but not lines that have it somewhere in the middle!

Do this:

Code: Select all

local tVinoDaAbbinare, tAbbinamenti
on mouseup
    ## Makes no sense here :-)
    ## set itemdel to TAB
   
   put fld "fldTblAbbinamenti" into tAbbinamenti

   ## This is the trick! 
   ## Also add a WILDCARD * at the end of the searchstring:
   put "*" & the selectedText of me & "*" into tVinoDaAbbinare
   filter tAbbinamenti with tVinoDaAbbinare
   ...
Best

Klaus

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

Re: Find with * & string

Post by francof » Sun Oct 26, 2014 9:37 am

ciao Klaus,
thanks for your time.
Klaus wrote:

Code: Select all

..
    ## Makes no sense here :-)
    ## set itemdel to TAB
 ...
Best

Klaus
yes, I suppose it. was an oversight emh :oops:

the problem remains, also with the wildcard * at the end of the search string the result is empty.

Code: Select all

on mouseup
   local tVinoDaAbbinare, tAbbinamenti
     
   put fld "fldTblAbbinamenti" into tAbbinamenti
   put "*" & the selectedText of me & "*" into tVinoDaAbbinare
   
   filter tAbbinamenti with tVinoDaAbbinare -- this don't works (tVinoDaAbbinare = *Carema*)
   --filter tAbbinamenti with "*Carema*"        --but the same value typed like a constant string  ("*Carema*") it works
end mouseup
may be something in my data?

best
franco

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Find with * & string

Post by jmburnod » Sun Oct 26, 2014 10:01 am

Ciao Franco,
I read your script and I don't find something wrong
Are you sure tVinoDaAbbinare = *Carema* ?
Best regards
Jean-Marc
https://alternatic.ch

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

Re: Find with * & string

Post by francof » Sun Oct 26, 2014 12:48 pm

bonjour Jean-Marc,
jmburnod wrote:Ciao Franco,
I read your script and I don't find something wrong
Are you sure tVinoDaAbbinare = *Carema* ?
Best regards
Jean-Marc
you got it. per la miseria...
there is a TAB after the name. this a screenshot of the Answer of the variable:
Immagine.jpg
very apparent.but, usually, I control the variable with a Brekpoint and hovering on it with the mouse. like this
Immagine1.jpg
Immagine1.jpg (5.39 KiB) Viewed 3811 times
here it's less evident.

when acquired the data, I used this function to remove duplicate lines from the variable:

Code: Select all

function deleteDuplicateLines theList                                        --this function removes duplicate lines from a list
   split theList by return and tab
   combine theList by return and tab
   replace tab & return with return in theList
   delete the last char of theList
   return theList
end deleteDuplicateLines
in this line of code: 'replace tab & return with return in theList' there was something wrong.
now it works fine. also without the second wildcard at the end of the serch string.

ciao
franco

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

Re: Find with * & string

Post by Klaus » Sun Oct 26, 2014 12:50 pm

Hi Franco,

quick guess, is the field with the "Mouseup" script LOCKED (locktext = true)?
If not, then it will NOT receive any "mouse" messages!


Best

Klaus

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

Re: Find with * & string

Post by francof » Sun Oct 26, 2014 4:33 pm

Ciao Klaus,

yes, the property locktext of the filed, in the property inspector, is checked.
the problem was in the data, again.

best
franco

Post Reply