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.

Newcomers DBPro Corner / can someone help me fix this error

Author
Message
BEAST
7
Years of Service
User Offline
Joined: 11th Jun 2012
Location: the gamecreators.com
Posted: 6th Jun 2013 23:04
I cannot run this rpg tutorial i get an error message that say "you have hit a FUNCTION declaration mid program!" can someone please help me

BM

Attachments

Login to view attachments
Lucas Tiridath
AGK Developer
11
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 7th Jun 2013 10:35
Hi BEAST. I've taken a look and the problem is that in your main source file (the one in which execution starts), you only have one function call.

When you include other source files, as you have done, they are actually appended on to the end of the main source file at compile time. This means that after Initialize_Menu() has run, execution moves on to the next commands. However as your other source files are filled with functions (as they should be), this means that the program hits a function declaration mid program and terminates.

To help you better understand what is happening, if you look inside your .dbpro file, you will see this.

This means that the content of each of the includes (1-5) will be appended to that of the main file and put into _Temp.dbsource. So the first thing the compiler will do is to add Initialize_Game.dba to the contents of RPG Tutorial.dba and so the code will look like this.

When you do this, the error becomes clear because after running Initialize_Menu(), the next non-comment line is the function declaration for Initialize_Menu().

To prevent this error, you need to ensure that you never hit a function mid program, either by adding an infinite main loop or an end statement. Adding an end statement to RPG Tutorial.dba like so

fixes the problem in as much as you don't hit a function during execution. However it does mean that as soon as your menu is initialised, the program closes again which is probably not what you want.

I hope that helps. Do let me know if you need any further help with this.

BEAST
7
Years of Service
User Offline
Joined: 11th Jun 2012
Location: the gamecreators.com
Posted: 12th Jun 2013 17:32
i did what you told but now dark basic the program run successful but i don't see anything i need more help

BM
Lucas Tiridath
AGK Developer
11
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 13th Jun 2013 00:02 Edited at: 13th Jun 2013 00:03
Hi Beast. We're happy to help, but please do try to be specific in your questions. This will help us to give you a better answer. The more detail you can give the better.

Quote: "the program run successful but i don't see anything i need more help"

I think what you mean here is that the app runs in fullscreen mode but the screen is black. Is this what you are experiencing? If so I've taken a look and I have noticed a couple of problems. The first is that in your Initialize_Menu() function

You call Sync On. This command means that you become responsible for refreshing the screen, rather than allowing the system to handle is. As such, you have to make sure that after using this command, you must call Sync once per loop. This can be done by adding the command to the end of the program's main loop found in the Main_Menu() function. Having done this, the background will appear but the buttons will not. There are a couple of reasons for this. First, in the main loop again, it looks like you need to call the Paste_Buttons() function each loop to get them to appear. In addition, because the placing of the buttons is absolute, you must make sure that the fullscreen resolution of your game is set to be 1024x768. Running on a lower screen resolution (as I initially was) will cause the buttons to be displayed off screen.

Having made these two changes, the Main_Menu() function should look something like this.


May I ask what tutorial you are working from? I notice that the source files are dated 2006. Of course, there is nothing wrong with that per say, but the language has change a bit over time which may explain why the original code is not working so well with the latest compiler.

This project seems to be a pretty complex one, and I wonder if you wouldn't benefit from working with something simpler to start with.

Still, I hope that helps. Do feel free to ask any further questions, although as I say, being specific about what you're trying to achieve and what problems you are having is a real help.

BEAST
7
Years of Service
User Offline
Joined: 11th Jun 2012
Location: the gamecreators.com
Posted: 13th Jun 2013 00:06
RPG Creation: A Technical Guide
the link to it is
http://forum.thegamecreators.com/?m=forum_view&t=89100&b=19

BM
Lucas Tiridath
AGK Developer
11
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 13th Jun 2013 00:27 Edited at: 13th Jun 2013 00:27
Thanks for the link Beast. Yes I'm sure this is a good tutorial but it is quite old and is a pretty advanced topic. It seems to be covering working on very large games, with a focus on having scripts/configuration files, encapsulated source files etc. This is all great stuff but it is rather complex. Have you tried any of the tutorials in this thread? I think there are a couple on making RPGs there too.

BEAST
7
Years of Service
User Offline
Joined: 11th Jun 2012
Location: the gamecreators.com
Posted: 13th Jun 2013 00:38
nah but i will check it out

BM

Login to post a reply

Server time is: 2020-01-20 19:03:01
Your offset time is: 2020-01-20 19:03:01