In our condition, we’re going to check for the first possibility - no match.Still, in the master copy of the Song component, add a condition under the Receive Trigger.If the function gives us anything other than -1 then this song matches our search and should be included in the results.If the function gives us the value -1 this means the song doesn’t match our search, and therefore should be excluded from the search results.When we execute indexOf(), it gives us back a number indicating the position of the found text, or -1 if no match is found. This will be the value we passed into the variable searchValue. searchValue is the keyword you’re looking for within source.source is the text you want to search through.It works with two parameters: source and searchValue. indexOf() looks through some text to see if some other text is present in it. We’re going to use ProtoPie’s built-in indexOf() function in our condition. Now we’d like to determine if the keyword matches any part of the song title. We’ve set up our Song component to receive the search keyword from the scene. Part 2: Displaying Results in the Search Box That’s what we’re doing here when we choose Assign to Variable. To enable this, click on the bug icon next to the variable name in the variable panel.įor debugging purposes, this is the way to see if a variable is storing the correct value.□ Whenever your Pie receives a message that has a value supplied along with it, you need to assign that value to a variable first before you can work with it. To see the value of a variable, display variables in the scene on the canvas and in the preview window. Trigger any response based on whatever change took place to a variable. Moreover, a value could be fixed or the result of a formula.Ĭontinuously detect any changes to a variable. A value could be of the text, number, or color data type. Assign ResponseĪssign a value to a variable. There is one trigger and one response that you often use with variables. Anything that's not a hex color code won't work. ColorĪ color variable stores a hex color code as a value. NumberĪ number variable stores numbers as a value. If you use a number as a value, the text variable will treat it as a text. The scope indicates where you can use the variable.Ī text variable stores text as a value. When creating a variable, there are two variable scopes to choose from. Long story short, a formula could contain variables while a variable could contain a formula as well. You would do this if you want to make a formula reusable across a scene. To take it a step further, a variable could store an entire formula (instead of just the result). To use the value stored in a variable, you need formulas. As a formula is an expression that "returns" a result, you might want to store this result to be used later. Think of a variable as a "basket" that stores a value. Use cases - Practical use cases on variables to learn from.įirst and foremost, formulas and variables do not exclude each other as you can use them independently from another.They automatically change dynamically as they always store the latest value. Predefined variables - A set of variables that are accessible anywhere.Enterprise planĬompletely new to variables? Jumpstart with the examples below and the other sections to get the most out of variables.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |