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 / What is the correct way to initialise an Array of Strings in AGK2?

Author
Message
Muckypaws
AGK Developer
13
Years of Service
User Offline
Joined: 21st Oct 2011
Location:
Posted: 31st Jan 2015 17:07
Hi,

What is the correct way to initialise an Array of Strings in AppGameKit 2?

Using the information available, I've defined the array as :-

global g_strArray$ as string [8] = ["C2", "C2", "E2","G2","G2","Z"," "," "]

This compiles fine, but when I try and run the program I get the following error

ByteCode Error, Array has no dimensions.

And this is before I try and use the array or process it.

I could use

g_strArray $[0] = "C2"
g_strArray $[1] = "C2"
g_strArray $[2] = "E2"
g_strArray $[3] = "G2"
g_strArray $[4] = "G2"
g_strArray $[5] = "Z"

And that works, but obviously very painful when I want to change or add data to the array.

So what is the correct way to allocate and initialise a String Array.

Many Thanks
Jason

https://www.facebook.com/WonkyPix
http://www.wonkypix.com
http://www.appstore.com/jsecconsultancyltd
paulrobson
10
Years of Service
User Offline
Joined: 22nd Nov 2014
Location: Norfolk, England
Posted: 31st Jan 2015 18:28
Bug already reported ; I think it was on the fixed list



Second works, first doesn't.
Muckypaws
AGK Developer
13
Years of Service
User Offline
Joined: 21st Oct 2011
Location:
Posted: 31st Jan 2015 20:33
Brilliant Thanks Paul!

Thought I was going mad

Is there an ETA for the next patch release of AppGameKit V2?

Kind Regards
Jason

https://www.facebook.com/WonkyPix
http://www.wonkypix.com
http://www.appstore.com/jsecconsultancyltd
Muckypaws
AGK Developer
13
Years of Service
User Offline
Joined: 21st Oct 2011
Location:
Posted: 31st Jan 2015 20:47
Ah, I spoke too soon Paul,


Nope that doesn't work in 2.0.10 I get a new message which is

Array Index out of Bounds, Index: 1 Array Length: <Empty> in main.ac at line blah....

Trying any index from 0 to x results in the same error

Kind Regards
Jason

https://www.facebook.com/WonkyPix
http://www.wonkypix.com
http://www.appstore.com/jsecconsultancyltd

Login to post a reply

Server time is: 2024-11-25 17:52:31
Your offset time is: 2024-11-25 17:52:31