Variable Issues

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
Dave Cox

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. 

Zsolt Olah

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.

 

Dave Cox

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.