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 / #include and function

Author
Message
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 22nd Feb 2014 11:38
Hi

I have some questions about #include and function.

I have a message error with my code (I tes the trial agk version before buy) :

main.agc



structures.agc
simple structure (type/entype) code

global.agc
global variable, dim if needed

lib.agc



the message :
could not understand command at line 36

How do I add function and #include in my files ?


Thank you for your answer.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 22nd Feb 2014 12:55
I'm probably missing something, but I can't see anything wrong with what your doing, should work IMO!

I am the one who knocks...
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 22nd Feb 2014 12:58 Edited at: 22nd Feb 2014 13:09
Could it be...

Which are not normal comments?

It would help if we had the line numbers

Edit:

Forget the comment about comments, I just tried this and they work - always learning eh?

So perhaps the space after the call but before the brackets?


Apart from that, as Van B says, the code looks fine.

Edit: Edit:

Another thought, are any of the spaces actually tab characters - I've had this in the past, eg. you cant use <tab> after #constant, but you can use it after the constant name
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 22nd Feb 2014 14:14
Remember to have blank lines at the end of every file.

fog
21
Years of Service
User Offline
Joined: 5th Oct 2003
Location: Newcastle, England
Posted: 22nd Feb 2014 14:18
SetSpriteposition should be SetSpritePosition.

Also you shouldn't have a space before your array brackets. I've no idea what AppGameKit will make of that.

Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 22nd Feb 2014 14:39
Hang on a mo!

There are 33 lines in the posted main.acg.

Assuming the include files are pulled in, in the order they are included and there is nothing else we are not seeing, then the error on line 36 is likely to be in the first include; structures.agc.

Which isn't posted.

So I'm not sure we can be of much help here.
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 22nd Feb 2014 15:03
Hi
Thank you for your answer.

I have modified my code (with all your remarks ), but I still have errors or crash...
I don't understand why, is the trial version stable enough to test ?


My new code is :

main.agc


infos.agc


structures.agc


global.agc



lib.agc
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 22nd Feb 2014 15:28 Edited at: 22nd Feb 2014 15:30
Ahh, remember when you use an include, you have to call a subroutine or function to actually do anything, like in your structures and globals code, make a structures_init and globals_init subroutine, and call them before doing anything else. The code won't execute on it's own, so includes have consist of routines or functions that you call. Usually I'd have an init routine and several functions in an included file.

I am the one who knocks...
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 22nd Feb 2014 15:45
@Van B : thank you a lot, I have understand .

I use include in some other langage, and it's not the same technic here.
The #include is just to use function, and not file.

Thank you again very much !
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 22nd Feb 2014 15:46
Types, constants and globals can be placed outside functions and subroutines in included files. This was an old bug.

Impetus73
13
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 23rd Feb 2014 18:15
Include, just copy the content of that file, and add it to the END of the main file, so they end up not being run, unless called, like Van B said.

----------------
AGK programmer
Did Amiga / AMOS programming in the 90's.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 24th Feb 2014 21:09
I find that using the Add Source File option in the editor will add a corrupted file which causes any code to fail.

I have to copy all the code from the newly added source file, open it in notepad++ delete everything, paste the copied code back into it then save it before the code will run successfully.

(Weirdly enough, I get the same issue in the DBPro editor too...)

Login to post a reply

Server time is: 2024-11-25 03:04:32
Your offset time is: 2024-11-25 03:04:32