Post about your Basic project here

Moderator: Mmiscool

User avatar
By Mmiscool
#51634 Return will let you contine exicuting from the place of the last gosub. It works.

If you use gosub you should be using a return at the end of branch being called in the gosub.
User avatar
By forlotto
#51670 Gotcha incorrect use in my case I wonder if it isn't the same for the other user.

So this is actually the correct use:

do some stuff 1
gosub [mysub]
return

[mysub]
do some stuff 2


Now what would the return actually do? I suppose this is something I should have really looked up rather than assuming I understood it correctly.

This is incorrect use of return as it ends the program:
do some stuff 1
gosub [mysub]
wait

[mysub]
do some stuff 2
return

So I thought I would return to the other wait basically more or less.

I suppose this is not the case so what functional purpose does it serve I suppose I should read into this a bit.

Thanks for clarifying sorry for my neglect on this one lol! Either way you can make stuff workable without it it seems just fine.
User avatar
By Mmiscool
#51675 I think you have a terrible misconception about gosub and return.
See the picture attached.
gosub.png


the return command will return the program to the line below where the gosub was.

Also gosub should never be used in place of a go to. There is a stack of return locations that will eventual get filled up if returns are not executed.
You do not have the required permissions to view the files attached to this post.
User avatar
By forlotto
#51730 And you have a good one so that should help everyone really.

Even myself!
But in reality my concept is not that far off of what you have just shown maybe I did something wrong in my testing but I am pretty sure I did something damn near the same and I got a DONE! message quite a few times it is possible that I did not have nothing to return to other than a wait maybe in this case it is best that I don't use return?

I know return was abruptly ending my programs though in some instances and it seemed as if it did not work in this manner in previous versions. Anyhow as you say I do have many misconceptions but what can I say a lot of the basic stuff is relatively new to me and really I have little or nothing to prove here I am learning just as everyone else there is little or no shame in understanding something slightly wrong I believe you have a bit of a misconception yourself with things as well at times the way you read and answer some responses they do not match the question being asked etc... Such is life we all make these large and subtle mistakes to errr is human ;)

Thanks for the excellent graphic and response mmiscool!
Add to documentation maybe?

-Ivan the Terrible :P