Exit/End Sub
Moderators:Administrator, Global Moderator
Using Gosub one can Return (line number) - can Exit or End Sub {or another statement in a Sub} return to a line number in the main prog section?? ???
-
- Full Member
- Posts:36
- Joined:Tue Mar 18, 2003 3:04 am
- Location:Lancashire, UK
- Contact:
Re: Exit/End Sub
no - sorry - end sub etc takes you back to where the sub was called. What you can do is set a flag if you want to take alternative actions on return
e.g. I have a search sub-routine which produces a result of 0 is no match found, 1 if a match found etc - the search sub is called and the flag% parameter is passed with a value of 0.
If the flag comes back to the calling routine as 0 then action (a) is taken, if 1 (found) then action (b)
If I remember correctly, a gosub has to be in the same module/subroutine for it to work and not outside it.
No doubt someone will correct me if I'm wrong!!
e.g. I have a search sub-routine which produces a result of 0 is no match found, 1 if a match found etc - the search sub is called and the flag% parameter is passed with a value of 0.
If the flag comes back to the calling routine as 0 then action (a) is taken, if 1 (found) then action (b)
If I remember correctly, a gosub has to be in the same module/subroutine for it to work and not outside it.
No doubt someone will correct me if I'm wrong!!