9 Replies
Chris Clift

Hi Russell

Really interested in your solution to convert ASCII to decimal. I've been trying to use your solution to work the other way round, i.e. decimal to ASCII. It's the javascript coding I'm having problems with, as I'm not a programmer and, despite looking at several online resources for javaScript programming (stack overflow etc) I still really can't make heads or tails of what they are saying as they use the examples in isolation and, although it is only likely to be 2 or 3 lines of text, I am unclear as to how to incorporate them into the Storyline Javascript. Any pointers would be gratefully appreciated.

Thanks in advance

Chris

Chris Clift

Hi Russell

Sorry to bother you again. I have been trying something similar to the solution you posted last time, that was brilliant by the way, only this time I'm trying to convert Decimal to Hex. I have tried the following code but with no success and wondered if you may be able to spot where I am going wrong.....or even if I'm barking up the right tree!!

Thanks in advance

Chris

<-------------------------------- code------------------------------------------------->

//I've named the variable to display the converted Hex value as 'HexOutput'

var player = GetPlayer();
var x = player.GetVar("NumericEntry");
var codeHex = x.toString(16).toUpperCase();
player.SetVar("HexOutput", ' ', '0x' + ('0000' + codeHex).substr(-4));

 

Russell Killips

Hi Chris,

You are close.

A little bit of background...

A numeric field can only be numbers. However, people have been wanting the initial value of a number to be blank.

Technically in order to do that. The number would have to be a string or text value. If its a string/text value it can be set to an empty string or be blank.

So in your javascript, you will want to make sure that the input is a Number and not a string.

var codeHex = Number(x).toString(16).toUpperCase();

This discussion is closed. You can start a new discussion or contact Articulate Support.