Change string into numeric variable

Jul 26, 2019

I have a test activity with 100 text variables (Q1-Q100) that are in fact numbers yet I needed string variables to use them in a printable report. Now, however, it turned out that it would be quite useful to add those numbers, but it is not possible as they are all string variables. I tried to use the code:

var player=GetPlayer();
var text = player.GetVar("Q1");
var number = integer.parse(text);
player.SetVar("N1", number);

to convert strings into numbers and save them as number variables (N1-N100) yet without success. Is there any working way of making it work, to convert that big number of variables and add them together using JS? I will be grateful for any help.

4 Replies
Lauren Connelly

Hi Artur!

Sounds like you're working on a stellar course!

At this time, Storyline isn't currently designed to expose system variables for user interaction. JavaScript triggers that reference them could interfere with course playback. And system variables that worked in earlier versions of Storyline might not work in later versions, such as Storyline 360.

I am interested to see how the community works with string variables!

Tech RockED

Hey folks, 
I have been working on algebraic expressions recently, the correct answer is shown on my system but if I upload the same on the application there will be a NaN error. I also got to know that if I click on "Enter" button from my keypad in my Mobile and then click on calculate button , I am getting the answer (i.e, string is getting converted into number when the "Enter" button is clicked).
How Do I get the answer on my first shot when I am clicking on calculate button directly (Without "Enter" button). I will be grateful for any help.

Here is my storyline file for the reference.


Lauren Connelly

Hello Tech RockED!

Thanks for sharing your file! To identify which specific action will turn the integers into a NaN value, I'd start by separating each action or step in the trigger. That should help troubleshoot from there.

If you need additional help, please don't hesitate to reach out to our Support Engineers by submitting a support case.