Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: xoart on March 16, 2015, 02:52:45 PM
-
Hi guys,
I am doing a search box and i would like it to be "autocomplete" or "incremental".
I have an array of string to store the variables, but the problem is that the only usable action i found is "string contains". With this action, if you don't put the exact letters, it will not detect the string.
For exemple, if you have this list:
red
cat
rectangle
rector
cheese
and you typed in "re", using the regular expression, it would find the following matches:
red
rectangle
rector
Do you know how to achieve that ?
-
Offhand, here's how I would do it:
1: Use a 'Get String Length' action on the string you typed
2: Use 'Array List Get Next' to run through the possible matches array, performing the following steps on each one.
3: Use the integer from step 1 with a 'Get String Left' action to reduce the strings you're trying to match to just the relevant characters at the beginning.
4: Use 'String Compare' to see if there's a match. If there is, add the string to the list of matches.
Let me know if that wasn't a clear explanation and I'll whip up an example package later.
-
The problem with this solution is that at the step 2 you need multiples variables to store the matches. This number is unknow (the software user can add strings to the array, so the matches can be numerous).
As far as i know playmaker does not allow to build variables at runtime, so it wouldn't work.
-
Maybe if we could make a non case-sensitive search ?
Or a non case-sentive contains action ?
-
I imagine I'd just store all the matches in their own temporary array, rather than as individual variables.
Regarding a non-case-sentive search action: This could be used to acheive the same effect with an extra step or two: http://hutonggames.com/playmakerforum/index.php?topic=4839.0
-
Hi,
You only need one temp variable you re use throughout your iteration over each array items. that works.
Bye,
Jean
-
Sorry to answer just now, indeed it works ;-)
Thank you very much !