Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling the main program from a sub?

Status
Not open for further replies.

quebasic2

Programmer
Dec 17, 2002
174
0
0
IN
Is it possible to call the main module of a program from one of its subs. I know that it would not usually be a good idea, but can it be done.
I also wondered if you could end a sub without using goto to call a tag just be for a end sub. Example of what I DON'T want to do:

sub win
If a=0 then goto endsub:
print "You Win!"
tallyscores
endsub:
end sub
 
In a word - no.
You can do it, if you need to use something in the main module you will have to move it to another SUB.
 
sub win
if a<>0 then
print &quot;you win&quot;
tallyscores
end if
end sub
 
Use 'Exit Sub'


Sub Win
if a=0 then Exit Sub
Print &quot;You Win!&quot;
tallyscores
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top