Problem on string.toInt() function

Anyone please show me an example to use

string.toInt() function

What have you tried so far?

int upperthreshold(String command)
{
    int highval = string.toInt(command);
    
    EEPROM.write(2000,highval);
    Serial.println(highval);
    EEPROM.read(2000);
    return 1 ;
    
}

here I am sending a string variable using Particle.function which triggers the above definition and I am passing value to “command” which is a string.Then I need that value in Integer format so I used the string.toInt() function.But I am getting error “error expected primary-expression before ‘.’ token”.

That pretty much tells you what's wrong :wink:

Just a hint: What type is command?

You could also search the forum or the net for toInt() :wink:

1 Like

sorry sir,
I did not get you

The error tells you where to put your primary expression.
Hint: It’s not between the brackets (where you’ve currently put it).

Sir command is of the type " String"

My code is here -

int upperthreshold(String command)
{
    int highval = string.toInt(command);
    
    EEPROM.write(2000,highval);
    Serial.println(highval);
    EEPROM.read(2000);
    return 1 ;
    
}    

This code is triggered using Particle.function

https://www.arduino.cc/en/Reference.StringToInt

or

https://community.particle.io/search?q=toInt()

1 Like

Whether s in string.toInt() is lowercase or uppercase because I am getting error “‘string’ was not declared in this scope”

And as per the documentation its lowercase

Thank you Sir,

I studied the code and found solution.