Page 1 of 1
Exit/End Sub
Posted: Tue May 13, 2003 4:33 pm
by Guest
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?? ???
Re: Exit/End Sub
Posted: Wed May 14, 2003 3:05 am
by John_Schofield
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!!
Re: Exit/End Sub
Posted: Wed May 14, 2003 9:32 am
by Guest
Thanks a bundle - thought that was the case
To John_Schofield
Posted: Thu May 15, 2003 9:36 am
by Guest
No, correction is necessary. You are correct in both remarks.