Sign in to follow this  
Followers 0
Xandy

Array memory allocation

3 posts in this topic

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?

Share this post


Link to post
Share on other sites



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

Why don't you use the UBound function?

1 person likes this

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0