Jump to content

Quick modification of array elements


Quinch
 Share

Recommended Posts

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
Link to comment
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
Link to comment
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.

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...