Variable Issues
Jan 12, 2017
By
Michael Wood
Hello Articulate Community,
I'm new to using variable in Storyline 2. I have created a simple name variable from a Text entry and I have two questions to the community.
1) Is there a way to create case sensitivity (E.g. text entry: mike / variable: Mike)
2) I am having problems running my tests with the %Name% variable (when I preview, the line of text becomes small)
I'm wondering if anyone has had this issue before, or if there is an easy fix that I am missing.
Thank you!
Mike.
8 Replies
Hi Michael,
Did you extend the text box to the right so that text won't resize to fit?
Hi Michael,
Yes, and yes.
First, your second question. Make sure that the text box for your variable is large enough to provide sufficient space for your variable when populated with the maximum amount of text that you expect to encounter.
Now the first, and slightly more difficult question, of trying to compare the contents of a variable when you don't know if it is upper or lower case. As usual, the solution is Javascript. Add this bit of javascript to a trigger. When the trigger is run, it will convert the variable "YourArticulateVariable" and convert it to lower case, and then put the new value in the variable "YourLowerCaseVariable". Of course, you will need to create these variables in your project.
var player=GetPlayer(); // get the player
var lowerCase = player.GetVar("YourArticulateVariable").toLowerCase(); // get the variable and convert it to lower case
player.SetVar("YourLowerCaseVariable",lowerCase); // return the lowercase string to another variable
Also keep in mind, javascript will only run in the published project.
Hi Dave,
I mess around with the text boxes. Didn't help, but I adjusted the font size and somehow that affected it.
As far as the JavaScript, thank you very much! I'll implement that code.
Michael,
If you right-click on the text box and select Format Shape -> then select Text Box, there's a setting of how the text box should behave in terms of Autofit.
Do not Autofit works well if you know you're not running out of the box with the variable and you don't want any changes to happen.
Shrink text shrink the text size. It can get ugly.
Resize shape does the opposite. Text remains the same size, and the box gets resized. It works if there's nothing else it would overlap.
Hi Michael,
No problem for me as long as text fields are wide enough.
Setup :
Preview :
Hi Dave,
I input the Javascript; however, I don't want everything in lower case, I want the first letter capitalised.
E.g. miChAel --> Michael
Try this :
var player=GetPlayer();
var firstLetterCapitalised = player.GetVar("TextEntry").charAt(0).toUpperCase() + player.GetVar("TextEntry").slice(1).toLowerCase();
player.SetVar("TextEntry",firstLetterCapitalised);
Hi Michael,
As Pierre points out, you can also use .toUpperCase().
For comparisons, it is usually best to just use .toUpperCase() or .toLowerCase(). as it gives you a predictable comparison. The code Pierre shows will allow you to set the variable with the first letter capitalized, and the rest in lower case.
This discussion is closed. You can start a new discussion or contact Articulate Support.