search

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

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

search

Post by robm80 » Mon May 19, 2014 5:10 am

Read my question in pictures with text underneath each picture:
sshot-7.jpg
search for cards with 'br' in the name
sshot-7.jpg (12.83 KiB) Viewed 8380 times
the answer is:
sshot-6.jpg
click one option and go to that card
sshot-6.jpg (17.72 KiB) Viewed 8380 times
How to do a search to find those cards and how to build pictures like these?

Thanks
Rob

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: search

Post by Simon » Mon May 19, 2014 6:05 am

Hi Rob,
I think what you are asking for is "substacks" and "palette". While this lesson isn't focused on your question it talks about adding substacks;
http://lessons.runrev.com/m/4071/l/7869 ... resides-in

At any rate substacks can be made like the images you show, I'm thinking you have them already you just need to attach them to a "mainStack", which they will act upon. Take a look at those (words in quotes) in the dictionary.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: search

Post by Simon » Mon May 19, 2014 6:42 am

Here more pics,
substack.jpg
So you just take the stacks you already have and change their Main Stack to the cards you want to search.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: search

Post by robm80 » Mon May 19, 2014 1:34 pm

I made myself not clear enough.
It is not that I want to import existing pictures.
I want to make a routine that asks for some letters in the name (my picture 1). then does a search (find?) and comes back with an answer (my picture 2).
Clicking on one of the founded cardnames will enter that card.

My problem: how to work with find.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: search

Post by Simon » Mon May 19, 2014 8:47 pm

Hi Rob,
With a field/variable that has all the names of your cards in it one per line:

Code: Select all

filter myVar with "*" &  fld "seachField" & "*"
In your top image on OK, it would filter all the lines of myVar (the list of your cards) with "br".
caseSensitive would be set to true for your first option
remove the wildcards "*" to get whole words only.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: search

Post by robm80 » Mon May 19, 2014 8:56 pm

For the moment I have to stop. By accident I deinstalled Livecode 6.5 and nothing works anymore.
Anyway thanks. I keep your advise on a safe place.

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: search

Post by robm80 » Mon May 19, 2014 9:34 pm

Everything is OK again, so I continue to learn about search.
I understand this script but don't know what to do with it : filter myVar with "*" & fld "searchField" & "*" :(

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: search

Post by Simon » Mon May 19, 2014 9:55 pm

Hi Rob,
Check out "filter" in the dictionary.
The simple form would be filter myVar with "*br*"
for
filter myVar with "*" & fld "searchField" & "*"
myVar would be a list of the names of your cards 1 per line
fld "seachField" is that field you show in the first image (I don't know it's real name)
"*" & fld "searchField" & "*" translates to "*br*" (using your example in the image)

Make any more sense?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: search

Post by robm80 » Tue May 20, 2014 6:34 am

The simple form would be filter myVar with "*br*"
Hi Simon,
Got it complitely. The quoted line is sufficient.

My script:
put fld "foo" into tVar
ask "what card"
filter tVar with it
go cd tVar


Great and many thanks :P
Rob

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: search

Post by robm80 » Tue May 20, 2014 6:51 am

Got it complitely. The quoted line is sufficient.
No, not complitely.
I don't know what to to with filter myVar with "*" & fld "searchField" & "*".
Suppose my field "foo" contents

George
John
Johnson
Pete

I ask for "ohn". How do I get an answer showing me John and Johnson ??

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: search

Post by Simon » Tue May 20, 2014 6:55 am

Hi Rob,
See the wildcards? ("*")

filter tVar with "*" & it & "*"

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: search

Post by robm80 » Tue May 20, 2014 8:11 pm

See the wildcards? ("*")
filter tVar with "*" & it & "*"
Hi Simon,
Although I have a fine working script:
on mouseUp
put fld "inhoud" into tVar
ask "what card"
filter tVar with "*" & it & "*"
if number of lines of tVar=1 then
go cd tVar
else
put the number of lines of tVar into tNum
repeat with i = 1 to tNum
put lineoffset(line i of tVar,fld "inhoud") &"." before line i of tVar
end repeat
ask tVar
go cd ( line it of fld "inhoud")
end if
end mouseUp


I use your wildcards-line but I don't know what it means: filter tVar with "*" & it & "*"
What's the function of the asterix and what does "it" do?

BTW: I know how you can declare a local variable, but how and where to declare a systemic variable?

Thanks
Rob

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: search

Post by Simon » Tue May 20, 2014 11:07 pm

Hi Rob,
I think it best you test using the wildcards on these.
Rob
Robert
Bertrand
Egbert
Telrob (OK I made that one up) :)

What happens if you use
it & "*"
"*" & it
it
"*" & it & "*"
Start with "b" then "be" using the 4 combinations above
Then try "r" then "ro" again with the 4 combos

OK here:
Filter_Rob.zip
LC 6.5
(1 KiB) Downloaded 208 times
Simon
Edit: Not sure what your second question means.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: search

Post by robm80 » Wed May 21, 2014 5:02 am

Thanks Simon, I start understanding.

it & "*"
"*" & it
it
"*" & it & "*"


The combi asterix and it determines the place of the char(s) first or last or every char.
Right ?
Not sure what your second question means.
I want a variable that you may use everywhere. A local variable just works on the script where that variable is declared. A systemic variable workst in the whole stack.

Thanks for your splendid lesson.
Rob

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: search

Post by Simon » Wed May 21, 2014 5:24 am

Hi ROb,
OK the second question...
"global variables"

Code: Select all

global gVar
on openCard
put 12 into gVar
end openCard
Then in a button

Code: Select all

global gVar
on mouseUp
answer gVar
end mouseUp
The key to remember is that you have to declare the global everywhere you use it as in the button example.

Now back to the filter...
Actually you would use "?" if you are just talking about characters.
The asterisk symbol "*" is for any number of characters before or after or "in" the filter (I don't know the correct term for the search term (maybe that's it!)).
We didn't do "in"
"rob" & "*" & "t"
also good

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply