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.

Author
Message
Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 4th Jul 2011 17:53
I have been away from this for a long time and am going through a book to get myself back into the swing of things. I have searched the forums and google and can't seem to find the answer.



This is the code and I get an error message that says you have hit a function declaration mid-program

I have tried wait key, end and loops in different places and nothing seems to work. Any ideas?

I am using the latest Blue IDE and the latest DBP upgrade. Not that release candidate but the latest stable upgrade.
=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 4th Jul 2011 18:00
You have to put function declarations at the bottom, and its good practice to put an end command between your source and function declarations to prevent that error.

Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 4th Jul 2011 18:19
I copied that right from the book, in my IDE I did have the function at the bottom, that was one of the things I tried to make it work. I put end between the source code and function and it just shows a black screen and then exits. If I put wait key in there all I get is the black screen. Shouldn't this return 12 or Number12?
Lucas Tiridath
AGK Developer
17
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 4th Jul 2011 18:52
PRoF is right, the problem is that functions need to be at the bottom. The reason you saw nothing when you put the function at the bottom was because nowhere in your program do you tell the computer to display anything. You only manipulate the variables. Try this code. You'll notice that as well as moving the function to the bottom, I've also added the "print" command followed by your number. This command tells the computer to display the contents of that variable on the screen.



Hope this helps.

Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 4th Jul 2011 19:00
Thanks that did it! I was looking things over and was just thinking about that and came back here to see if I had an answer and you had it. These guys that did this book didn't make the code examples user friendly which is OK because it makes you think! I actually had this figured out before I saw your response. Thanks!

Login to post a reply

Server time is: 2026-07-11 00:55:49
Your offset time is: 2026-07-11 00:55:49