I know there is no specific code for this and some women's intuition is better than others, but I am going to give some tips. In the past it was taboo for women to approach men while they are out with their girls. But now more often than not it seems women have been mustering up their confidence to talk to a guy they find attractive. So, how do you know when it's time to walk away? Well, if he is not giving you eye contact and looking around is one good sign. Another is eye rolling and looking at his friend in a suggestive way (I just saw this happen and it was pretty embarrassing!) You have to look carefully for that sign. Also, body language is he leaning into you or away from you.
Also, he will subtly touch you if he is interested, but remember some guys are just friendly so be careful with this one. With men they aren't very emotional, it is or it isn't. Women tend to over analyze way too much with most situations, because we are first and foremost emotional and they are first logical. Watch his hands to see what they are doing, mens hands normally get twitchy when they are intimidated or like someone.
Always remember though if you strike out, at least you tried! And don't think just because one guy didn't like you that means all of them won't! There are millions of men out there and eventually you will meet your match! Just remember to have fun with it, because dating should be fun, not the headache people make it out to be!