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 / "Array does not exist" at runtime in Tier1 ????????????????????

Author
Message
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 18th Mar 2012 07:39
Hello

I've a strange Tier1 problem with some global Arrays which becomes undeclared at specific moments at runtime when i read or set it a value. Obviously i've verified GLOBAL DIM declarations (and it worked well before without any modifications)....

AGK IDE tells me "Array does not exist at line XXXX in root" during the runtime and the app stops (running on windows). On iOS Player the interpreter completely shuts down at the same moment.

It's always the same array, except if i add a simple "active" command like a print("..."):Sync() before the error line... at this time it's the next (a different one) array which becomes undeclared !

The problem started to happen when i added a subtype in a subtype of another subtype of a type of an array .... lol

Any idea of what's happening ? maybe a problem of characters encoding in my agc file ? i had strange problems using characters accents sometimes in my code comments .... (this time i have deleted them :p but doesn't resolve my very strange issue)
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 18th Mar 2012 09:33
Do you resize your array? If you do it's possible that not all data is copied over and if it isn't, then it may not exist. I can't confirm this though. I've seen examples where resizing multidimensional arrays lose data.

MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 18th Mar 2012 10:03 Edited at: 18th Mar 2012 10:05
i don't resize arrays (only dimmed once at start of main.agc) ... and i'm not only loosing data ... i'm loosing the entire array because it says me that it does not exist ! (as a missing dim statement !)
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 18th Mar 2012 12:23
Could the problem be something else?

Usually when I get the "Array does not exist" error, it turns out to be something that's not an array and was never meant to be.

A Typing mistake, misplaced punctuation or something else which is being picked up when an array is expected.

The fact it jumps from array to array seems to support this idea as does your comment about comments.
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 18th Mar 2012 17:22
yes but i don't see such a thing ...

i'm still investigating ...

maybe i have too many subtypes ? lol
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 18th Mar 2012 21:11 Edited at: 18th Mar 2012 21:12
i managed to reproduce my problem ! =)

It seems depending on the number of var declared in a type, and depending where (and how many) variables are declared as an existing type, compiler have some problems to maintain an array of type ...



try and run this code and try to comment the lines i've marked one after each other :



Any idea ?
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 18th Mar 2012 21:21
Quote: "Any idea ?"

I have heard (I can't remember if it's a written rule however) that one should not declare variables as a TYPE inside a function, even if it isn't being used. Still, it is strange.

MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 18th Mar 2012 21:25
very strange ... why can i declare one typed variable but not a second one ? (with only one it works well !)

and the compiler doesn't throw an error on this declaration, but on the array ...

And it also depends on the number of variable in the type's definition ... very strange ...
zenman
15
Years of Service
User Offline
Joined: 16th Jan 2009
Location:
Posted: 19th Mar 2012 00:48
What funny is i put "global myvarSOD as SOD" and no error.
zenman
15
Years of Service
User Offline
Joined: 16th Jan 2009
Location:
Posted: 19th Mar 2012 01:19
Also if you put myvarSOD as SOD after the print it works but if I put myvarSAD as SAD after the print it blows.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 19th Mar 2012 03:47 Edited at: 19th Mar 2012 03:47
I seem to remember reading types within types are bugged in AppGameKit (to some extent), that could explain the semi randomness of the problem. The new version is supposed to fix it though, which isn't far off ( I hope lol). I don't tend to use them all that much, and find myself using regular arrays more often than not, so never seen the issue here.
I know declaring types in a separate file is a no no, if you split your program over multi files.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 19th Mar 2012 09:22
I wouldn't declare types or dim arrays for the first time within a function or subroutine as this can cause problems.

MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 19th Mar 2012 09:28
@baxslash : it's not the case. Type is defined at the start. I only try to declare a defined type variable in a local function (as an integer or a string ! nothing more). I don't want to declare all my typed vars as global in the main code for obvious reasons.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 19th Mar 2012 17:27
I ran into similar problems that made me crazy.

I had code that suddenly started dying when it hit certain statements. And it appeared to be somewhat related to where the lines of code sat.

In one case, if I put a do nothing statement like assigning a string to a variable that isn't used, the line where the program failed would shift.

I eventually figured out that the issue was definitely due to UDTs within UDTs that are in an array.

The type setup looks like this:


If I passed the 'isAt' element in a black hole directly into a function call, the results would be fine the first time a level is played. But the second time (after you've fallen into the black hole or gone off the edge), the results would be scrambled.

This fails:


And this fixed the problem:


I was trying to figure out a simple example that would show the problem (a small extract from my project just doesn't happen easily now).

Thank you, MikeMax, for coming up with one.

And I do hope this is fixed in the next version.

Oh, my black hole works very nicely. I had fun figuring the right equations and forces/impulses, etc. to get the gravity well and event horizon working right.

Cheers,
Ancient Lady
LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 1st Apr 2012 20:22 Edited at: 1st Apr 2012 20:22
Thanks for locating the bug to a specific instance Have you posted this and the reproducible to the issues board (http://code.google.com/p/agk/issues/list)? I am pretty sure what this issue might be, but having the code in the issues board will help a lot, thanks!

I drink tea, and in my spare time I write software.

Login to post a reply

Server time is: 2024-05-03 17:44:52
Your offset time is: 2024-05-03 17:44:52