WIFI Connect When Available?

I have already connected a MKR1000 to my wifi network when my project is first turned on.


#include <WiFi101.h>

char ssid[] = "NETWORK";
char pass[] = "PASSWORD";
int keyIndex = 0;
int status = WL_IDLE_STATUS;
WiFiServer server(80);

void setup() {

  while ( status != WL_CONNECTED) {
    Serial.print("Connecting Network: ");
    status = WiFi.begin(ssid, pass);

But my new project will leave my residence, store some variables out side, then when I return home, I would like to press a button, reconnect to the network and then send the data (to Thingspeak for example)

Can I run the setup connection in a loop function and call it when the button is pressed?

Have Googled up and down but I figure my wording is inadequate to find what I am looking for. Any tips on wording for searching for this solution is greatly appreciated.

Of course, you can move it to the loop() function. Followed by a while(connected)...