Blog Post
PaulRodger
Community Member
Tobias this was good. Just a couple of points is there any way to be able to type in the field without having to delete the 0? I felt I lost some time doing that. The speech bubble at the end slightly covers his face (not a biggie) but it might look a bit nicer if the stem was brought back a bit
TobiasNoeske
5 years agoCommunity Member
I so far have not found any way to remove the 0. As stated above I recycled an older project which had the same issue which I couldn't resolve until now. Apparently unlike text input variables you can't set a numeric variable to "blank". If I use a text variable instead I can't do any calculations. Converting variable types would probably require some JavaScript which I hardly have any experience with.
By the way: you don't need to delete the 0, just type the desired number behind the 0.
As for the speech bubble: Well spotted. I'll fix that.
By the way: you don't need to delete the 0, just type the desired number behind the 0.
As for the speech bubble: Well spotted. I'll fix that.
- MathNotermans-95 years agoCommunity Memberi do think Storyline treats variables always as strings...so internally a Number will be converted to a string anyway...
How to do that yourself ?
So how to use strings for your input... and then convert them as Numbers..well thats easy...
to convert any string to a Number Javascript has an standard function called parseInt()
parseInt(input);
this will return a Number...
samples:
===========================
var input = "12";
var myNum = parseInt(input);
console.log(myNum);
=====================
var input = "05";
var myNum = parseInt(input);
console.log(myNum);
===========================
Note: If the first character cannot be converted to a number, parseInt() returns NaN.
So if using a space or non-numeric character you get NaN as return... so you have to check that too... buildin function isNaN( ) can handle that...
var input = "";
var myNum = parseInt(input);
if(isNaN(test){
console.log("this :"+myNum+": aint a number, NaN");
}else{
console.log(myNum);
}
===========================
Hope this helps a bit :-)- TobiasNoeske5 years agoCommunity MemberThanks, that certainly helped! As mentioned before I hardly know any JS so any idea and common way to solve typical issues is highly welcome.