I have to agree with everyone else: it all comes down to one word--
planning. Before I go to a restaurant, I look up their menu online (all chains and most locally owned restaurants here have their menus online), and I decide
exactly what I will order, including what modifications I will request. As far as going to people houses or places where there will be snacky foods, I plan as far as the foods I know will be there, and I spend days psyching myself up to stay on program. Even if I know that I am going to eat something off program, I plan that little cheat, and resolve that that will be my only cheat.
So, plan, plan, plan, and you will do just fine!! You've got to believe that you are capable of succeeding at this, and I know you can!!