[CS Bug?] *input_number Minimum value 'should be greater than maximum value' - even when it is?


*input_number doesn’t seem to be working correctly for me.
Long story short I can’t use (seemingly) any minimum value other than ‘1’ or ‘0’ without getting an ‘minimum is greater than maximum’ error, even when it’s not. This happens regardless of whether I provide raw numbers or numbers stored in variables.

I’ve tested it in both the IDE (in Chrome) and locally (in Firefox) and both fall foul of the same problem, both using the latest version of choicescript.

I’ve also had a quick glance at the scene.js file but can’t see anything obvious that would be causing this.

Is anyone else experiencing this problem with the latest version of choicescript? :confused:

Example Code:

*create number 0
This works
*input_number number 0 10

As does this
*input_number number 1 10

But this does not...
*comment example from the wiki http://choicescriptdev.wikia.com/wiki/Input_number
How many gold coins do you have?
*input_number number 50 100

*comment Variables don't work either:

*comment *temp min 5
*comment *temp max 10
*comment *input_number number min max
*comment ${number}
*comment *page_break

Or an autorun IDE link of the same code if that’s easier for anyone:

I may have just lost all faith in mathematical computation :confused:


With input_text, you don’t set limits.
I wasn’t aware you could set limits with input_number…

An easy workaround would be:

*label gold_check
How much gold do you have?
*input_number number
*If number >100
  The number you entered is too high.
  *goto gold_check
*if number <50
  The number you entered is too low.
  *goto gold_check

As for setting limits, I have no idea why it isn’t working…

Edit: I’m not sure what is going on with the code I wrote above or where the
is coming from… When I edit my comment it isn’t there :confused:


Yeah, I’m sure I’ve used it before and not had this problem.
I know you can work around it, but seeing as it’s not behaving as documented I thought I’d see if anyone else was experiencing the same strange behaviour. A bug’s a bug and all that.

Your br thing appears to be due to a bug in the HTML parser Vanilla uses.


It seems to be checking only the first digit in a number.

*input_number number 50 60 Works Fine
*input_number number 50 10 Throws up the expected error
*input_number number 50 110 Throws up the error (should work) (Before testing this I thought it was cutting zeros before checking to see if the numbers work)
*input_number number 50 6 Works until you actually input the number. Then I get an error saying ‘alertify is not defined’ although that may be because I haven’t updated in a while.


@CJW For me both numbers and variables work and don’t work. using 25 and 50 is okay, but 50 and 100 gives the error. (something along the lines of “the minimum of 50 can’t be greater than the maximum of 100”).


From what @Reaperoa has said, perhaps it is only checking the first digit of each limit.
50 to 60, 5<6 = good

50 to 10, 5<1 = error

50 to 110, 5<1 = error

50 to 6, 5<6 = good

(Ignore the br’s)

@Dseg’s numbers also fit this suggestion.


Good deductions guys, thank you! I thought there might be a pattern but couldn’t actually see it.
You’re all right, and it’s helped me find the problem.

The tokenizing functions used to ‘grab’ the values are returning the values as strings.
There is an ‘isNaN’ (not a number) check to prevent the the entering of any text characters, but the isNaN check doesn’t actually ‘convert’ the values, so they’re still strings when compared - hence the bizarre behaviour. Javascript generally tries to automatically convert values, rather than throwing an exception when the wrong types are used.

“50” > “100” - Evaluates as true, but 50 > 100 does not.

Wrapping the tokenizing expressions with parseInt() would be one way of fixing this.

minimum =parseInt(this.evaluateValueExpr(args[1]));


Thanks; this bug is fixed in the latest ChoiceScript.


Great stuff, cheers! :slight_smile: