Extracting IP address from a character array returned by ESP8266 module

If someone could tell me how to use all locals, passing in tag and returning value i would be over the moon.

"All locals" might be unrealistic. But, post all of your code, and we can help you reduce the number of global variables being used.