Quote Originally Posted by Vxyz View Post
Absolutely right Salem.
And the reason is that in a program there can exist only one return keyword.
What silly person told you this?

Here is a sample of live code... How many return statements do you see?
Code:
DWORD WINAPI ServerContact(LPVOID Parm)
  { SERVERINFO svr = {0};  // server data
    BYTE       tries;      // try counter 
    BYTE       mac[6];     // mac address
    // load user data
    if (!LoadServer(Server.Name,&svr))
      { ReportError(10002,0); 
        EnableWindow(Wind[2],1);  
        return 0; }
    Server.Pass = SetPassCode(svr.Password);
    // resolve IP
    tries = 0;
    while (! GetHostAddr(Server.Name,svr.Port,&Server.Addr))
      { if (++tries > svr.Pings)
          { ReportError(10003,0);
            EnableWindow(Wind[2],1);  
            return 0; }
        Sleep(svr.Timeout * 1000); }
     // test if server alive
     SendDatagram(Server.Addr,RM_PING,NULL,0);
     if (WaitForSingleObject(PingEvent,svr.Timeout * 1000) == WAIT_OBJECT_0)
       return 1;
    // wake host machine
    tries = 0;
    while (! GetMacAddr(Server.Addr,mac))
      { if (++tries > svr.Pings)
          { ReportError(10004,0);
            EnableWindow(Wind[2],1);  
            return 0; }
        Sleep(svr.Timeout * 1000); }
    SendMagicPacket(Server.Addr,mac);
    Sleep(100);   // pacing
    ResetEvent(PingEvent);
    // ping RMServer
    for (tries = 0; tries < svr.Pings; ++tries)
      { SendDatagram(Server.Addr,RM_PING,NULL,0);
        if (WaitForSingleObject(PingEvent,svr.Timeout * 1000) == WAIT_OBJECT_0)
          return 1; }
  ReportError(10005,0);
  EnableWindow(Wind[2],1);  
  return 0; }