Many times, like me, you might have defined variables as strings or Text variables as we call them in Articulate Storyline. These variables, though defined as “Text” may contain numeric values too. This makes it easier to enter numeric values inside a “Text” field and use it for comparisons.
Number variables allow very few comparison operators whereas text variables include a lot of comparison operators. Also, assigning default number types might result in unnecessary decimal points. Therefore, populating a “Text” variable with a numeric value and using it after conversion will help you use a lot of operators easily, when needed.
For a recent project, I had to convert text variables to number variables. I’ll share how I overcame this issue following a few simple steps.
Step 1: Create Variables
In this step, we have to create variables using the default feature of Storyline. There are three types of variables in Storyline:
For this scenario, we have to create one Text and one Number variable. As shown in the screenshots below, select the variable type by clicking the Type dropdown list. Populating the values of these variables through the data entry box is optional.
Step 2:Add Triggers
Step 3: Add the Script
var player = GetPlayer();
vartextvariable = player.GetVar(“textvariable”);
textvariable = (textvariable * 1.00052658);
numbervariable = textvariable;
Step 4: Reference the Variable
Now we have to address the converted variable, i.e., the number variable. For that, you can go to “Insert”, click the “Reference” button and select the number variable.
The value stored in the text variable will be shown through the number variable.
I hope this blog helps you accomplish this task easily and swiftly.
Please share your thoughts.
Subscribe to Our Blogs
Get CommLab's latest eLearning articles straight to your inbox. Enter your email address below: