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 Classic Chat / reached exit without being in a loop in function

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 31st Jul 2016 08:50 Edited at: 31st Jul 2016 09:07
Hi.

When I click on Exit button, give me this message:



Reached "exit" without being in a loop in functions.agc at line 736.

In Functions.agc at line 736 I have this codes:



I think when I don't have Do---Loop command in my Function, this message show me. but when I remove exit in above code,below code won't work:



anyone know what is this Message and how can fix it?

Thanks.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 31st Jul 2016 09:51
exit is for loops,
use exitfunction
AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 31st Jul 2016 10:00
Thanks For Reply.

Quote: "exit is for loops,
use exitfunction"


I used exitfunction but this code won't work.

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 31st Jul 2016 10:04
?
if GetPointerPressed() = 1 then exit
if GetPointerPressed() = 1 then exitfunction
AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 31st Jul 2016 10:12
I wrote it in do --loop.

also I used blow codes but don't exit function.


Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 31st Jul 2016 10:21 Edited at: 31st Jul 2016 12:07
when I use exitfunction in my Functions.agc then exit command won't work this below code and make stop loop and freeze all other buttons . but don't get Reached "exit" without being in a loop in functions.agc at line 736. message.



I don't know this is a problem in my code or it's a bug.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 31st Jul 2016 13:27
i don't know what is outside of your CreateNextRound.
if your app freeze then i guess it is anywhere without a sync()
my suggestion, a function should only do what the function name describe and the condition when it is used is outside.
AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 31st Jul 2016 13:34
Quote: "i don't know what is outside of your CreateNextRound."


my CreateNextRound go to Next Round (Round 2) when Player is Win.

Quote: "if your app freeze then i guess it is anywhere without a sync()"


my button are in do---loop with sync() command but after use exitfunction in my functions.agc and when player is GameOver, then exit command won't work . for sure I remove Gameover Function but still exit command won't work.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 31st Jul 2016 13:34
Quote: "i don't know what is outside of your CreateNextRound."


my CreateNextRound go to Next Round (Round 2) when Player is Win.

Quote: "if your app freeze then i guess it is anywhere without a sync()"


my button are in do---loop with sync() command but after use exitfunction in my functions.agc and when player is GameOver, then exit command won't work . for sure I remove Gameover Function but still exit command won't work.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 31st Jul 2016 13:53
exit command only works if it is direct in a loop

do
Anything()
Sync()
loop

function Anything()
exit <<<<<<< this don't work
endfunction

-------------------------

do
if Anything()=1 then exit //this will work
Sync()
loop

function Anything()
ret=1
endfunction ret

AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 31st Jul 2016 14:34
A second opinion for you...It is exactly as Markus says.
You cannot Exit from a function.
You can only ExitFunction from a function

The compiler is telling you this.

(By the way, Report Post is for reporting bad behaviour and inappropriate posts. It is not for reporting problems with your code )
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 31st Jul 2016 15:02 Edited at: 31st Jul 2016 15:19
Quote: "A second opinion for you...It is exactly as Markus says.
You cannot Exit from a function.
You can only ExitFunction from a function

The compiler is telling you this."


I used exit command for my older games and work very well, but this is the first time I see this error.
and currently i used exitfunction instead exit command but it don't work and run main.agc.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 31st Jul 2016 15:05 Edited at: 31st Jul 2016 19:49
really I'm confused.

this is my game menu exit code:



but I don't know why run main.agc.

It occurs when I change exit to exitfunction in Functions.agc.

I think Problem is relate to below function. I change exit command to exitfunction but won't work it. but when I comment below function, exit button work correctly. seem when this function is running, can't exit the function and when I click on exit button, it load main.agc. so how we can exit from this function?



anyone have any suggestion ?
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 31st Jul 2016 21:20
I find Problem.

Thanks Markus, Now I understand your mean. I use your way for exit function and now all things work very well.

JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 1st Aug 2016 06:32
Why do you have the 'do loop' part within your function? This seems like a very bad thing to do...your function should be inside a 'do loop', not the other way around. Also, why do you need to exit the function? It's hard to tell what you're exactly doing. You may be making your code way more complicated than it should. When it comes to coding games, simple is better, don't make things more complex than they need to be.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 2nd Aug 2016 00:41
Quote: "I used exit command for my older games and work very well, but this is the first time I see this error."

maybe source code from agk v1 and now you are using agk v2? i believe the compiler for v2 was rewritten.
AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 2nd Aug 2016 06:53 Edited at: 2nd Aug 2016 07:04
@JLMoondog

Quote: "Why do you have the 'do loop' part within your function? This seems like a very bad thing to do...your function should be inside a 'do loop', not the other way around. "


because if I write all thing in main do--loop, it's make increase line code and find problems or error is very hard.

@Markus

Quote: "maybe source code from agk v1 and now you are using agk v2? i believe the compiler for v2 was rewritten."


yes, I think it is.
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 6th Aug 2016 10:33
if you want to close the game use end instead of exit
life\'s one big game
spec= 2.6ghz, 1gb ram, 512mb gpu, directx 9.0c, dbpro and classic
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 12th Aug 2016 00:06
Was probably blind luck that the end of your loop was also at the end of your function. It's an awesome coding style. Keep typing in random commands, eventually you'll find one that looks like it does what you want. Haha.

V2 T1 (Mostly)
Phone Tap!
Uzmadesign

Login to post a reply

Server time is: 2024-11-17 10:18:59
Your offset time is: 2024-11-17 10:18:59