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 / Unusual behaviour for a function

Author
Message
Psycho Psam
16
Years of Service
User Offline
Joined: 3rd Apr 2008
Location: Western Australia
Posted: 13th Jul 2012 05:18
I have a function which is sitting in a file called resourceHandler.agc and is included by main.agc.

When I run this code during the main loop, unless I put a print("") command in it, the screen goes blank and I am assuming it never returns from that function. This was the main reason for putting a print command in there, but without it, it never returns. Anyone else encountered this? The code works fine once the print command is present.

Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 13th Jul 2012 05:41
Why do you have both a "return" (from gosub) and an "endfunction" call?

I used to hate the thought of governments having orbital mind control satellites,
but now I can't really seem to care.
Psycho Psam
16
Years of Service
User Offline
Joined: 3rd Apr 2008
Location: Western Australia
Posted: 13th Jul 2012 05:56
Oh that shouldn't be in there. It was put in when I was trying to get it to come back. I found I couldn't gosub processUpKeep( something ) as it spits the error "Parameter mismatch in expression 'processUpKeep'. So I just called the function by typing processUpKeep( something ). When it first showed the black screen problem, is when I put the return in - assuming calling a function without gosub would need it.
I just took out the return then anyway and it still has the problem that if I take out the print command it never returns from that function.

Is it because I'm doing all this stuff in an included file? Do most people just use 1 file for everything? I'm getting some other weird errors which might come from this method of using included files.

Ref: http://forum.thegamecreators.com/?m=forum_view&b=41&t=198262&p=0
lilpissywilly
AGK Developer
13
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 13th Jul 2012 10:55
I can only confirm that it's not due to using included files. I have all my functions in several included files in all my projects

My hovercraft is full of eels
Psycho Psam
16
Years of Service
User Offline
Joined: 3rd Apr 2008
Location: Western Australia
Posted: 13th Jul 2012 11:02 Edited at: 13th Jul 2012 11:03
I'm just wondering why I'm getting all these weird errors and no one else is? Like making a function work by putting a print command in, or leaving a print command out to make another piece of code not crash.

I have windows 7 running on. 64 bit machine using agk 1075.

I'm seriously thinking of ditching it because I waste so much time with these silly errors.
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 13th Jul 2012 13:11
Quote: "I have windows 7 running on. 64 bit machine using agk 1075."

Have you tried upgrading to 1076? It might make a difference, it might not.

If the project isn't too large, I'd be happy to take a look at it.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 13th Jul 2012 15:22 Edited at: 13th Jul 2012 15:37
Firstly, have you now removed the remnants of the gosub method? They may be interfering, and causing memory location issues.

If it still doesn't work, create yourself a debug file. At the very simplest level, open the file at the beginning of your program, and close it at the end. In between, write lines out to it to establish where you got to, and the state of any important parameters.

Longer term, make yourself a set of debug functions to manage debugging output to a file. It may take a couple of hours now, but save so much more time later.

Psycho Psam
16
Years of Service
User Offline
Joined: 3rd Apr 2008
Location: Western Australia
Posted: 13th Jul 2012 16:44
Yes the gosub functionality has been removed. I'll try the debug function as you've mentioned.
Psycho Psam
16
Years of Service
User Offline
Joined: 3rd Apr 2008
Location: Western Australia
Posted: 31st Jul 2012 12:25
This is resolved as mentioned in this thread. I was trying to mix gosubs and function calls. You can't.

http://forum.thegamecreators.com/?m=forum_view&t=199054&b=41

Thanks for everyone's help

Login to post a reply

Server time is: 2024-04-27 20:02:09
Your offset time is: 2024-04-27 20:02:09