When reading a floating point number from an InputTextField, it should be noted, that there can be different decimal notations, based on the users selection of language.
English language would use dot-notation (e.g. 1.5) where e.g. French would use comma-notation (e.g. 1,5) - this is also the raw text that would be read from the input field using the getText() method.
As URScript will need dot-notation for decimal separation, it is good practice to ensure that the number parsed will have this format.
This can e.g. be done in the following ways, depending on whether the input is desired as float or String.
Hi, I have a issue related with this topic. When I’m trying to read a float number with an InputTextField, just like in the Whip URCap sample, the simulator notifies me of an error. It can’t read numbers with decimal notations…
@Input(id="numanalog")
public void onNumanalogChange(InputEvent event){
if(event.getEventType() == InputEvent.EventType.ON_CHANGE){
Numero = Float.parseFloat(numanalog.getText());
// Se pone la variable analĂłgica al valor leĂdo
VariableAO.setValue(Numero);
How can I read a float number from an InputTextField?
“Numero” is a variable where I save the number read.