Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / [SOLVED] return must be fallowed by a new line?

Years of Service
User Offline
Joined: 26th Jun 2020
Posted: 15th Apr 2023 16:37

this code is telling me that return must be fallowed by a new line but as far as i can tell my code is correct

The author of this post has marked a post as an answer.

Go to answer

James H
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 15th Apr 2023 18:37 Edited at: 15th Apr 2023 18:38
This post has been marked by the post author as the answer.
return is for subroutines, for a function you just add the variable after "endfunction" which means calling the function like so; variable=functionname()
Win 10 Home 64, Intel(R) Core(TM) i5-10300H, 8GB DDR4, NVidia GeForce GTX 1650 4GB GDDR6
Years of Service
User Offline
Joined: 26th Jun 2020
Posted: 15th Apr 2023 20:22
thank you!
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 15th Apr 2023 21:48
ExitFunction [Return Variable] for Mid-Function Returns
EndFunction [Return Variable] for End-of-Function Returns

You can also alternatively use "Ref" to use the Imported Variable "as-is" rather than the Function creating a copy of it

Now we can define a Program Label with the ":" Operation at the end of a Variable Name.

This isn't to be confused with when you use it with a space

myLabel :

As this will mean "New Line" instead of defining a Label

Now with a Program Label we can either GoTo [Label] which will continue the program at that Label., or if we add a Return... i.e.

myLabel: : Print( "This Prints when I call GoSub myLabel" ) : Return

Then we can use the GoSub, and when it reaches the Return., it will go back to where the GoSub was called from and continue on
Now as a note., we can ONLY use these in #Include or Main Source... and we also can't use them within Functions., as Labels are ALWAYS Globally defined rather than Locally defined (as is the case in C/C++)
So in situations where you _wouldn't_ traditionally use labels to bounce around code... you HAVE to use Functions instead.

Login to post a reply

Server time is: 2023-06-06 13:45:11
Your offset time is: 2023-06-06 13:45:11