manoj,
Usually when people ask this type of question, they are trying to sequence the operation of a machine - for example:
... now the door is moving downward - I need to keep the door moving downward until the “door closed” limit switch comes on - then I need to ...
Is this the type of thing that you’re trying to do? If it is, then “staying in a subroutine” is not the correct way to go about it.
If I’ve guessed wrong, then why don’t you tell us what you’re trying to accomplish? I’m sure that some of the guys here can offer some excellent advice on how to get the job done.
And if you’re a student who is just experimenting with subroutines - that’s ok too - but it would be a good idea to tell us so. There are a lot of “wild and crazy” things that can be done for educational purposes - as long as there are no safety concerns or “lost production” issues involved. Right now we’re mostly just guessing about how to help you out. More information would certainly make it easier on all concerned.
And exactly what type of processor are you using? That makes a big difference.