WHY THERE IS A DO LOOP

Nov 18, 2014 at 7:57 AM
im getting error because i tried the sample code in source code section.
  var tn = new Terminal("127.0.0.1", 23, 10, 80, 40); // hostname, port, timeout [s], width, height
            tn.Connect(); // physcial connection
            do
            {
                string f = tn.WaitForString("Login");
                if (f == null)
                    throw new TerminalException("No login possible");
                Console.WriteLine(tn.VirtualScreen.Hardcopy().TrimEnd());
                tn.SendResponse("telnet", true); // send username
                f = tn.WaitForString("Password");
                if (f == null)
                    throw new TerminalException("No password prompt found");
                Console.WriteLine(tn.VirtualScreen.Hardcopy().TrimEnd());
                tn.SendResponse("telnet", true); // send password 
                f = tn.WaitForString(">");
                if (f == null)
                    throw new TerminalException("No > prompt found");
                tn.SendResponse("dir", true); // send dir command
                if (tn.WaitForChangedScreen())
                    Console.WriteLine(tn.VirtualScreen.Hardcopy().TrimEnd());
                BatchProcessDemo b = new BatchProcessDemo(tn, "mybat.bat", new Uri("ftp://172.16.16.20/myb.bat"), "c:\\", (ICredentials)new NetworkCredential("SHASHANK-AC86C3\\Telnet", "shashank185")); ;
                b.ExecuteScript();
            }
            while (false);
What is the purpose of the do loop? i removed the loop and my application is working.
Coordinator
Nov 19, 2014 at 6:56 PM
The sole reason of the do is that I can break at any time. This is not obvious from the example, but as an example
if (f == null) break;