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 / Issues with resizing float arrays

Author
Message
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 10th Jul 2014 00:55
I don't use float arrays very often and I'm glad!
I just was using one to do some benchmarking and came out with very wrong values.

Here's the sample code:


Here's the output (resized array is very wrong -- pre-sized is spot on)


I figured folks should know if they don't already.
This was with AppGameKit 10821 tier 1

Just ran a test in v2 and it's fine there, just a warning to any working in v1.

Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 12th Jul 2014 06:28
Quote: "I don't use float arrays very often and I'm glad!"

You shouldn't be afraid of using an array of floats. Integer vs float shouldn't make a difference when it comes to resizing. On most OSs they're the same size.

I had the same problem maybe two years ago with resizing multidimensional arrays. Anyway, seems to be fixed in the next version.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 22nd Jul 2014 22:28
I suspect that the issue might be related to your initial 'dim' statement: dim _my_array#[0,4]

Using zero as a dimension probably doesn't work and confuses AGK.

You are defining a two dimension array. Internal to AppGameKit, it uses the dimensions to calculate offsets. Zero definitely messes it up.

While you can use zero as an index, you do need to use at least one as a dimension.

Cheers,
Ancient Lady
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 23rd Jul 2014 06:42
Nah even if you initialize it as
dim _my_array#[1,4] it messes up the data on resize.
I use a zero dimension when initializing my arrays I know will be resized. T1 sero dimension arrays actually are one element arrays (dim with size 10 and you have 11 elements - yay basic). So it actually has a dimension and works fine that way with the other data types.
Doesn't really matter Paul seems to have fixed it in V2.

swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 23rd Jul 2014 07:33
I feel like I'm shamefully advertising a product saying this but I've stopped using arrays entirely. My memblock code I posted has been much more powerful and reliable. Even with the release of v2, I'm not sure I'll use any arrays. Having pointers is just too powerful, despite the complications and drawbacks. (which would be greatly reduced if errors reported a stack trace as opposed to only the line on which an error occurred)

Login to post a reply

Server time is: 2024-04-26 15:38:24
Your offset time is: 2024-04-26 15:38:24