Exit/End Sub

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators: Administrator, Global Moderator

Post Reply
Guest

Exit/End Sub

Post 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??  ???
John_Schofield
Full Member
Posts: 36
Joined: Tue Mar 18, 2003 3:04 am
Location: Lancashire, UK
Contact:

Re: Exit/End Sub

Post 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!! ;-)
Guest

Re: Exit/End Sub

Post by Guest »

Thanks a bundle - thought that was the case
Guest

To John_Schofield

Post by Guest »

No, correction is necessary.  You are correct in both remarks.
Post Reply