how to save a msg acording to the switch

Hello all,
I want to connect a a simple on\off switch.
that if he will be in off - it will save a message "enter"
and if its on "leave".
how do I do this ?
after I will use the status of the switch in the PIR motion detection

this is what I wrote so far - but something is not good in the definition of the msg

thanks ,

void loop ()
{
dir_cheak();
if (d==0)
{
if (digitalRead(piry3)==HIGH)
{
Serial.println($msg1);
delay(4000);
Serial.println("Active");
}
else
Serial.println($msg2);
delay(4000);
Serial.println("Active");

int dir_cheak()
{
int d;
char msg;
if (digitalRead(direct)==LOW) //switch off enter the zone
{
d=0;
msg1=("enter the zone");
}
else // switch is on leaving the zone
{
d=1;
msg2="leaving the zone"
}
return d,msg;
}

$msg1
msg1=("enter the zone");
return d,msg;

This isn't even C so of course it won't compile.

int d;
...
return d...;

You should not return a local variable.

I think you should study the C language and learn the proper syntax.


Rob