Sign in to follow this  
Followers 0
Quinch

Quick modification of array elements

5 posts in this topic

#1 ·  Posted (edited)

There's probably a simple way to do this, but I can't seem to find it; I'm trying to find a way to quickly insert a series of values into a two-dimensional array. I know I can do this when I'm initially declaring the array, but I will need to do that long after the array has been declared.

An example would be;

Dim $Actors[10][9]

{stuff happens, and I now have some of the variables I'll need to input into the array, and I want to insert nine values into the first row}

HypotheticalInsertIntoArrayFunction($Actors[0], 1, 2, 3, 4, 5, 6, 7, 8, 9)

Regards,

Quinch

EDIT: A quick clarification, I know I can modify individual values with $var[0][0] = "bleh", or setting up a function with a For/Next loop, but it seems as though it would seriously slow down the script.

Edited by Quinch

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

you could use for loop to do that

EDIT: Sorry haven't seen you already wrote that. But it is still the best way to do it

Edited by searchresult

Share this post


Link to post
Share on other sites

There's probably a simple way to do this, but I can't seem to find it; I'm trying to find a way to quickly insert a series of values into a two-dimensional array. I know I can do this when I'm initially declaring the array, but I will need to do that long after the array has been declared.

An example would be;

Dim $Actors[10][9]

{stuff happens, and I now have some of the variables I'll need to input into the array, and I want to insert nine values into the first row}

HypotheticalInsertIntoArrayFunction($Actors[0], 1, 2, 3, 4, 5, 6, 7, 8, 9)

Regards,

Quinch

EDIT: A quick clarification, I know I can modify individual values with $var[0][0] = "bleh", or setting up a function with a For/Next loop, but it seems as though it would seriously slow down the script.

Some For/Next loops would be the ONLY way to do this, but 10x9 array only has 90 elements and can be completely re-written in a few microseconds. Unless your real array is MUCH bigger, time won't be a significant factor.

Also, you did say "insert" not "overwrite", so you would first have to change the size of the array without destroying data, using REDIM, before moving/adding data.

Read up on REDIM in the help file.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Some For/Next loops would be the ONLY way to do this, but 10x9 array only has 90 elements and can be completely re-written in a few microseconds. Unless your real array is MUCH bigger, time won't be a significant factor.

Also, you did say "insert" not "overwrite", so you would first have to change the size of the array without destroying data, using REDIM, before moving/adding data.

Read up on REDIM in the help file.

:)

Yeah, odds are the size of the dimensions might be in the deep hundreds, so time might become an issue {mostly due to lots of testing and retesting, but I can test with smaller arrays}. Also, yeah, originally it's insert since the array will be created blank {thus, values would need to be "inserted" into the array}, but overwrite/modify would have been a less misleading term. Anyhow, thanks for the help.

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