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 / Feature request. Which array access?

Author
Message
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 30th Nov 2016 12:38 Edited at: 1st Dec 2016 11:22
I sometimes have several multidimensionel arrays accesses in the same line, and when I have a dimension too many, the compiler in Tier 1 just says "Array access has to many dimensions", not which one of my arrays. There is something similar when I have entered too few dimensions, it does not tell me which array is accessed in-correctly.
13/0
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 30th Nov 2016 13:36
Do you have a code example of this?
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 30th Nov 2016 13:45
hmm, debug like this and put a$ in debugger output or print it at screen?
or check .length
a$="Step1": ArrayAccess1:a$="Step2": ArrayAccess2:a$="Step3": ArrayAccess3
https://www.appgamekit.com/documentation/guides/12_array_changes.htm
AGK (Steam) V2.0.21 : Windows 10 Pro 64 Bit : AMD (16.6) Radeon R7 265 : Mac mini OS Sierra (10.12)
damothegreat
User Banned
Posted: 30th Nov 2016 13:47
I'm not sure if there is any limitation of multidemension arrays

let us see if we all get the same issue, if u could send a small snippet that causing the failure


Damo
Using Tier 1 AppGameKit V2
Started coding with AMOS
Anything is possible if put mind to it
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 1st Dec 2016 11:22 Edited at: 1st Dec 2016 11:25
CumQuat: Yes.

Markus: I do not access out of bounds, I just forget a dimension or have one too many.

Damothegreat: I have not run into a limitation for dimensions in an array. I have forget a dimension or added one too many when trying to access the array.

Here is a small example, un-rem the two last lines individually to see each error.



EDIT: The problem is that I access several arrays in the same line sometimes, and I have to check each array individually to find where I forgot a dimension or added one too many. It would be nice if it gave me the name of the array.
13/0
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 1st Dec 2016 16:29 Edited at: 1st Dec 2016 16:29
ahh,
hmm,

in this case i would made this

//print(test_array_1[1,test_array_2[1,1],1,1]

=

a=test_array_xy[1,1]
print(test_array_4d[1,a,1,1]

and rename it
dim test_array_threed[10,10,10]
dim test_array_xy[10,2]
AGK (Steam) V2.0.21 : Windows 10 Pro 64 Bit : AMD (16.6) Radeon R7 265 : Mac mini OS Sierra (10.12)
damothegreat
User Banned
Posted: 1st Dec 2016 17:47
Try this



Can you see any suttle differences at all between mine and yours

Damo
Using Tier 1 AppGameKit V2
Started coding with AMOS
Anything is possible if put mind to it
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 1st Dec 2016 20:06
Quote: "You have an extra ",1" here when the test_array_1 only has 3 dimensions declared"


Isn't that the entire point of the thread?


A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
http://games.joshkirklin.com/sulium
damothegreat
User Banned
Posted: 1st Dec 2016 20:31
It is not programaticaly possible to add extra definitions to an array after its been defined

Defined as "dim test_array_1[10,10,10] " // 3 arguments in the dimension

The code was used was using 4 arguments

print ( test_array_1 [ 1, 1, 1, 1 ] ) // 4 arguments /dimensions - its just not possible

D






Using Tier 1 AppGameKit V2
Started coding with AMOS
Anything is possible if put mind to it
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 1st Dec 2016 22:51
Ahhhhh I see

Yeah, DamoTheGreat hit the nail on the head
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 2nd Dec 2016 03:30
Cybermind. I think your suggestion is a very good idea. It would be great if the compiler named the array that was referenced incorrectly (Or even included an offset of where the error occurred)
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 2nd Dec 2016 05:56
Quote: "It is not programaticaly possible to add extra definitions to an array after its been defined

Defined as "dim test_array_1[10,10,10] " // 3 arguments in the dimension

The code was used was using 4 arguments

print ( test_array_1 [ 1, 1, 1, 1 ] ) // 4 arguments /dimensions - its just not possible

D
"


Yes, that is the point, he knows this is invalid and that it will throw an error. The intent is not to modify the array. He wants to know specifically which array is causing the error when multiple arrays are used on the same line.


A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
http://games.joshkirklin.com/sulium
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 2nd Dec 2016 20:22
Ortu is absolutely right I am not trying to modify the array after it has been declared. The code I have posted here is overly simplified, real life problem is that I sometimes reference several (many) multidimensional arrays in the same line. Any error here is horrible to backtrack, I have to find each array's declare point, look at the line, try to look at the array declareration again, look at the line some more, until I find one or two arrays that was accessed incorrectly.
13/0
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 2nd Dec 2016 20:38
maybe use a function to read/write from your array then i expect a better error message.

also think about to rename your arrays
dim blah_with_3_arguments[10,10,10]
dim blah_with_4_arguments[10,10,10,10]
AGK (Steam) V2.0.21 : Windows 10 Pro 64 Bit : AMD (16.6) Radeon R7 265 : Mac mini OS Sierra (10.12)
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 2nd Dec 2016 21:58 Edited at: 2nd Dec 2016 22:03
Indicating the dimensions involved the name isn't a bad idea as a convention if you use a lot of multidimension arrays

Not sure you really want the overhead of a function call everytime you need to access an array, and function parameter errors can be just as obtuse as array errors


A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
http://games.joshkirklin.com/sulium
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 2nd Dec 2016 22:29
@Ortu
Quote: "overhead "

It depends on what he is doing.
i favor control & overview instead of bugs.

AGK (Steam) V2.0.21 : Windows 10 Pro 64 Bit : AMD (16.6) Radeon R7 265 : Mac mini OS Sierra (10.12)
damothegreat
User Banned
Posted: 2nd Dec 2016 22:42
I just cannot comprehend why anyone would wanna cause a failure in finding bugsof this nature.

Unless @Cybermind is trying to answe a programming degree question and needs some of our ideas.

In reality - we just wouldn't want to try and trap errors if not really necessary to


Using Tier 1 AppGameKit V2
Started coding with AMOS
Anything is possible if put mind to it
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 2nd Dec 2016 23:55 Edited at: 2nd Dec 2016 23:58
Cybermind uses arrays to store the index of other arrays.
As such he can have a line of code that will reference half a dozen arrays or more.
When there is an error, say when he has coded too few dimensions, he wants the compiler to print the array name (that is in error) in the error message

i think it is a very good idea
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 3rd Dec 2016 10:01
Filtered into one row
@paul
Quote: "say when he has coded too few dimensions, he wants the compiler to print the array name (that is in error) in the error message"
AGK (Steam) V2.0.21 : Windows 10 Pro 64 Bit : AMD (16.6) Radeon R7 265 : Mac mini OS Sierra (10.12)
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 5th Dec 2016 10:19
Quote: "Filtered into one row
@paul
Quote: "say when he has coded too few dimensions, he wants the compiler to print the array name (that is in error) in the error message""


And also a name of the array when I have coded too many dimensions
13/0
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 5th Dec 2016 16:29
Quote: "say when he has coded too few dimensions, he wants the compiler to print the array name (that is in error) in the error message ... also a name of the array when I have coded too many dimensions "

Added to the next version
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 5th Dec 2016 19:38
I love The Game Creators and their rapid and continuous development I started with DBC, then DBP and now AGK2 Thumps up for this great team!
13/0

Login to post a reply

Server time is: 2024-03-29 01:54:26
Your offset time is: 2024-03-29 01:54:26