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 / I don't understand this compiler error

Author
Message
Uechi
18
Years of Service
User Offline
Joined: 2nd Sep 2006
Location:
Posted: 5th May 2012 01:23
Cannot find structure "createMap:i" in local declaration at line 85
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 5th May 2012 01:33
Code please?

Uechi
18
Years of Service
User Offline
Joined: 2nd Sep 2006
Location:
Posted: 5th May 2012 03:08 Edited at: 5th May 2012 03:09
Here is the code with some stuff commented out
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 5th May 2012 03:37 Edited at: 5th May 2012 03:44
You need to either initialise the globals i, x, y or set their datatypes. Simply having:


isn't enough because at this stage they could be either integers, floats or strings.

Edit: On second thought, they could be integers when declared as such but assigning them a value such as 0 seems to solve the problem.

Uechi
18
Years of Service
User Offline
Joined: 2nd Sep 2006
Location:
Posted: 5th May 2012 03:49
changed them to integer and got same error

Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 5th May 2012 04:57
Sorry, I was looking at about 5 projects at once and when I thought I was compiling yours, I compiled something else.

Anyway, it looks like you can't use global iterators in for loops when those for-loops are in functions.

A work around for now would be to make i, y, x local and then pass them in as arguments.

DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 6th May 2012 19:48
I doubt it has anything to do with it, but I notice you use the inc command. I have not had much luck with that command in AGK. It may be ok now, but in older versions of AppGameKit, it used to be dodgy. I went back to the old school a=a+b method, and all the odd bugs disappeared.
If it is a global/local variable thing, you could just change it to a gosub routine. That would eliminate that aspect, and for what the function does, a gosub is exactly the same.

Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 6th May 2012 23:38 Edited at: 6th May 2012 23:52
While I applaud the programming discipline of declaring everything at the start, in this case it seems to be the cause of the problem

Try removing the global declarations for rows, cols, x, y and i and see if that helps.

From the code provided, I can see no reason why these need to be global, they are local loop counters and are not referenced outside those loops.

Also, within the bombExists() function, x and y are used in a local context - they are created locally to received the passed parameters - and I'm not sure if that will work with them also being global.

Another thing, you don't need to include width and height as parameters to bombExists(), as these are also global so would be seen within that function anyway.

So this could be simplified to.


Finally, it might help if you set width and height to a value somewhere

edit:
@DVader
Quote: "I notice you use the inc command. I have not had much luck with that command in AGK"

I had some issues at first, and did as you did going back to maths.

But I started using it again in 1065 and have not had any issues when using it with integers. Floats, on the other hand, freaked it out big time under 1065, I've not tried under 107x

I don't know how much inc saves over a normal addition - perhaps a couple of cycles for the extra move operations, but can't imagine it would be a lot, especially in relation to floating point maths.
Uechi
18
Years of Service
User Offline
Joined: 2nd Sep 2006
Location:
Posted: 7th May 2012 18:00
thanks to everyone for their suggestions. I made them local and it solved the problem

Login to post a reply

Server time is: 2024-11-23 11:28:45
Your offset time is: 2024-11-23 11:28:45