Convert post form variable to float?


I am attempting to receive a form variable called “position” that is posted from a website. The problem is that the variable needs to be a float between 0.0 and 1.0. I am retrieving the variable inside of a Rocky api post method and attempting to convert that to a string. No matter how I assign the variables it can’t find the toFloat() method on the variable. Here is my code:"/set-position", function (context){

local postedPosition = null;

#if (!("position" in context.req.body)) {
#    context.send(400, { message = "Missing Required Parameter 'position'" });
#    return;

postedPosition = context.req.body.position;

local position = postedPosition.toFloat();

server.log("/set-position recevied : " + position);

servo_position = position;

context.send(200, "OK");


Thank you!

It’s “tofloat()” (all lowercase).

It sure is! Thanks Hugo!

My brain just registered the f in tofloat as capitalized using this page’s font: look as capitalized.