tired of looking Anyone Please

SteveMan. Once again thanks for your help. Ive tried code you provided and it keeps trying to connect continually as before.. its not incrementing the count. Ill lookat it and go through examples if i can find any when i get chance..
Ive tried that, but it makes all sorts of problems. Battery backup on alarm sounds alarm. Difficult to lock/unlock. Time consuming reprogramming after reconnection.

There is a line of code missing. Try this:

  while (WiFi.status() != WL_CONNECTED and numberOfRetries <= MAX_RETRIES)
    Serial.print("Attempting to connect to SSID: ");
    WiFi.begin(ssid, pass); // Connect to WPA/WPA2 network. Change this line if using open or WEP network

Not tested. Not even compiled.

Well Done And thanks so much..
Works a charm, finely i can get some sleep and concentrate on more important things.
Thanks to everyone who has taken the time to help
Regards Jim