Jump to content

Simple question about arrays in AutoIT


Recommended Posts

Hello! I am trying to make a little application that keeps track of character movement.

Character moves from Pt a to pt B, and I would like to keep track of the last 100 movements or so. What I would LIKE to do would be:

have

$Global $pt[2]

$Global $move[2]

$Global $movementArray[100]

pt[0] = $blahX

pt[1] = $blahY

$move[0] = $pt

$pt[0] = $blahX

$pt[1] = $blahY

$move[1] = $pt

_arrayPush($movementArray, $move)

However, I have no Idea if I can do this in autoit. I have a feeling that I will have to set up separate arrays for xPosition, and yPositions.

All these arrays will be passed back and forth between functions.

Thanks for any help and advice you can give.

Link to comment
Share on other sites

Hello! I am trying to make a little application that keeps track of character movement.

Character moves from Pt a to pt B, and I would like to keep track of the last 100 movements or so. What I would LIKE to do would be:

have

$Global $pt[2]

$Global $move[2]

$Global $movementArray[100]

pt[0] = $blahX

pt[1] = $blahY

$move[0] = $pt

$pt[0] = $blahX

$pt[1] = $blahY

$move[1] = $pt

_arrayPush($movementArray, $move)

However, I have no Idea if I can do this in autoit. I have a feeling that I will have to set up separate arrays for xPosition, and yPositions.

All these arrays will be passed back and forth between functions.

Thanks for any help and advice you can give.

$aCords[1][1]

For $i = 0 To 100
;check for your cords here
     ReDim $aCords[$i+1][$i+1]
     $aCords[$i][0] = $xcord
     $aCords[0][$i] = $ycord
Next

Not sure if thats what your looking for but it will store x and y in a 2D array

Edited by LurchMan

Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Link to comment
Share on other sites

I'm sure it can be done but you didn't give us any detailed code to work with so the best I can do is point out a couple of errors in what you did give us.

Global $pt[2] ;; Don't use $ infront of Global, Local or Dim
Global $move[2]
Global $movementArray[100]

$pt[0] = $blahX;; On these 2 lines you forgot that pt is a variable so it must use the $
$pt[1] = $blahY

$move[0] = $pt

$pt[0] = $blahX
$pt[1] = $blahY

$move[1] = $pt

_arrayPush($movementArray, $move)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I'm sure it can be done but you didn't give us any detailed code to work with so the best I can do is point out a couple of errors in what you did give us.

Thanks for the Assistance. I guess, what I am really trying to do is make a data structure that consists of a

1) movementArray. The movement array is single dimensional and each item in movementArray is a movement.

2) movement.

Each item in a movement consists of 2 points.

I understand that all variables in AutoIt are variants, so they necessarily can be arrays. However, I read in the autoit array wiki page that nested arrays were perhaps not desirable. What I am looking for is some advice on whether I should go about this project like this, or should I just have one data structure $movementArray[100][4]. Where

$movementArray[n][0] = starting pt x

$movementArray[n][1] = starting pt y

$movementArray[n][2] = ending pt x

$movementArray[n][3] = ending pt y

Thanks for any help / advice you can give.

Link to comment
Share on other sites

If the values won't change then I would opt for the Large Multi-dim array. If that's not the case then multiple arrays will be better.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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