Jump to content

Array memory allocation


 Share

Go to solution Solved by FireFox,

Recommended Posts

Passing arrays with size included is very convenient for scope.  I know I'm late to the party.

It works great for 1 dimension arrays.  I'm not sure how to do it with 2 dimensional arrays without possibly wasting memory.

I may have read a long time ago that AutoIt used a pointer like system in which array indexes didn't really take up space until filled with data.  

local $world_size[2]
$world_size[0]= 320
$world_size[1]= 320
 
local $world[$world_size[0]][$world_size[1]]
$world[0][0]= $world_size[0]
$world[0][1]= $world_size[1]
 
ConsoleWrite($world[0][0])

 

I could shift the x world data to account for the size and pass the array around without xmax ymax parameter syntax.  I'd still be wasting 318 units of whatever memory.  I know I could make an array with 3 elements shove the [0]xmax, [1]ymax, [2]world array into it pass it around and access [2]world with a dummy variable.  Is that the way I should do it?  Is there something I should read to being me up to date as how this should be done?

Link to comment
Share on other sites

Why don't you use the UBound function?

It's extra call assignment line(s) for each accessing function, that I only need to assign once during a load routine.  Reads cleaner to me.  Fewer lines.

I didn't know Ubound() had a Dimension parameter!

Now I do. 

I will consider your advice greatly as I will probably now be using a Ubound() system.

Thank you!

Edited by Xandy
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...