Variables - numeric vs alpha
May 24, 2016 12:00 AM
I've been experimenting a lot with variables and am completely stumped. I know that variables can be both numeric and alpha. Is there a way to force numbers into an alpha string? For example, I'd like for a string of numbers to show like this 93510911. I'd also like for the numbers to be visible one at a time as the student enters the number.
Discussion (6)
Yeah, I zipped the one up without the space in the variable. To fix it just edit the variable I created and put a single space at the beginning.
Great example Darrel! I'm getting a ~null~ string at the beginning of the text when I preview in Chrome?
Great - thanks. In looking over your example, it appears all I needed was an entry field versus a variable?
I do think ALL variables in Lectora are always Strings.
Try with Darrel's sample, you can as easy use characters in the inputfields and it works as well. To make sure a variable contains only numerics you need to use either Javascript or add some extra check to make sure the user only adds numbers. I suspect the Lectora default calculations ( addition/subtraction etc. ) do a conversion internally. In fact i just tried based on Darrel's sample to make an addition.... and its clear it even stays strings when using the Lectora calculations....
Offcourse you can force an inputfield to only accept numerics...but they stay Strings...and get converted to a numeric internally by Lectora.
Discussions have been disabled for this post