Simple String to Variable (int?) conversion help , newbie

Hello, I am having fun trying to do what i think is a simple task and getting nowhere. Im using the Arduino IDE to program the ESP8266 -12 F I am programing using arduino 1.6.8 (ARDUINO CC) Problem.. I have a string ( this = "1234" ) I want to convert this to a value so (that = 1234)

I have successfully read a text.txt file from a webpage to a string and it contains ascii characters 60. I want to read this into a variable (called an int on C I think) so I can feed it into a program to adjust a delay. so I can decrement or increment it like its a register. ( I have a few years experience in Assembly coding but this is so alien)

I have searched for a few hours and found all sorts of rubbish that does not work for me. I have failed to get strtol and toint to obey my demands! they just produce errors (invalid conversion from 'const char to int) and many more.

I am new to this Arduino C stuff and require a nice easy example so as not to confuse the new boy. cheers.

Your thread title says String. The body says string. There is no code so that we can check.

There is a function, atoi(), if you really have a string. If you have a String, there is documentation that you should look at.

Hello, Thank you for the reply, I know very little about C programing. I have managed to fix my problem after deciphering an example.
I have read that there is a difference between string and String, but alas I don’t know what it is, but that’s not important for me at this stage. (I should read a few books on this I know!)
Here is the section of code that had me stuck. It now converts the ASCII (S)/string to a decimal value.

The program reads the analog port and stores it in a .txt file via a .php script on the webserver.
It then reads a Wait_Time.txt containing the ASCII number chars from the webserver.
The program then puts the ESP8266 to sleep for the number of seconds in the .txt file.

Heres a short section that stumped me.

if(httpCode1 == HTTP_CODE_OK) {
String payload2 = http.getString(); Gets responce as ASCII text from the .txt file.
USE_SERIAL.println(payload2); Just displays it to serial port for debugging.
USE_SERIAL.printf("\n\r");
long waittime = strtol(payload2.c_str() ,NULL ,10); Converts it to a numeric value!

Thanks for help.

Have a look at the parse example in Serial Input Basics

The String class (capital S) can cause problems in the small memory of an Arduino. Better to use cstrings which are char arrays terminated with a 0 - as in the above link.

...R

       long waittime = strtol(payload2.c_str() ,NULL ,10);  Converts it to a numeric value!

I'm willing to be a box of donuts that google knows all about the strtol() function.

PaulS: I'm willing to be a box of donuts

Do post a photo :)

...R