Jump to content
Sign in to follow this  
Wylim

MultiDimensional Arrays

Recommended Posts

Wylim

This is my current code if anyone could tell me what is wrong with it to make it a multi dimensional array I would appreciate the help.

Dim $Plex ;Setting $Plex as an Array

$Plex = _ArrayCreate(

_ArrayCreate("154","59","167","70", "Hel") ;Cwadarkone Hell Plex

_ArrayCreate("86","165","95","184","Sur") ;Cwadarkone Surface Plex 1

_ArrayCreate("156","69","171","73","Sur") ;Cwadarkone Surface Plex 2

_ArrayCreate("269","0","298","29","Sur") ;Cwadarkone Surface Plex 3

_ArrayCreate("278","126","289","130","Sur") ;Cwadarkone Surface Plex 4

_ArrayCreate("0","0","58","8","Sky") ;Cwadarkone Sky Plex 1

_ArrayCreate("0","10","8","18","Sky") ;Cwadarkone Sky Plex 2

_ArrayCreate("53","55","63","64","Sky") ;Cwadarkone Sky Plex 3

_ArrayCreate("235","53","250","67","Sky") ;Cwadarkone Sky Plex 4

_ArrayCreate("204","56","222","70","Hev") ;Cwadarkone Heaven Plex 1

)

This script is meant to be a form of a macro for a game I play and I currently have no idea what I'm doing wrong with these arrays any help would be appreciated. I already know how to work with them and am a PHP Programmer so I'm not sure what's going wrong here.

Share this post


Link to post
Share on other sites
Wylim

Well I figured it out on my own. I'm not sure if anyone else has noticed this about multidimensional arrays but you can not have any space between arrays. This is a bit different then I am used to but it isn't a problem.

$Plex = _arrayCreate(_arrayCreate("154","59","167","70", "Hel"),_arrayCreate("86","165","95","184","Sur"),_arrayCreate("156","69","171","73","Sur"),_arrayCreate("269","0","298","29","Sur"),_arrayCreate("278","126","289","130","Sur"),_arrayCreate("0","0","58","8","Sky"),_arrayCreate("0","10","8","18","Sky"),_arrayCreate("53","55","63","64","Sky"),_arrayCreate("235","53","250","67","Sky"),_arrayCreate("204","56","222","70","Hev"))

My current code ended up working I just had to add "," and take out all of the spacing I had. This is still a bit of a problem for what I wanted to do with it but not a major one it's just not pretty to read.

Share this post


Link to post
Share on other sites
steveR

You could have wrote it like this, the _ is a line continuation character:

#include <array.au3>

Dim $Plex;Setting $Plex as an Array
$Plex = _ArrayCreate( _
_ArrayCreate("154","59","167","70", "Hel"), _ 
_ArrayCreate("86","165","95","184","Sur"), _ 
_ArrayCreate("156","69","171","73","Sur"), _ 
_ArrayCreate("269","0","298","29","Sur"), _ 
_ArrayCreate("278","126","289","130","Sur"), _
_ArrayCreate("0","0","58","8","Sky"), _ 
_ArrayCreate("0","10","8","18","Sky"), _
_ArrayCreate("53","55","63","64","Sky"), _
_ArrayCreate("235","53","250","67","Sky"), _
_ArrayCreate("204","56","222","70","Hev") _
)

AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.

Share this post


Link to post
Share on other sites
Wylim

Well I'm having another problem. Now I am recieving this error message.

$XStart = $Plex[1][1]

$XStart = ^ERROR

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

Does anyone know what the subscipt dimension max range is because it doesn't seem to be very large.

Here is my current code not sure exactly what parts are needed so heres two parts of it and the file will also be attached if you need further information.

Dim $Plex ;Setting $Plex as an Array Variable.

$Plex = _ArrayCreate( _

_ArrayCreate("154","59","167","70", "Hel"), _

_ArrayCreate("86","165","95","184","Sur"), _

_ArrayCreate("156","69","171","73","Sur"), _

_ArrayCreate("269","0","298","29","Sur"), _

_ArrayCreate("278","126","289","130","Sur"), _

_ArrayCreate("0","0","58","8","Sky"), _

_ArrayCreate("0","10","8","18","Sky"), _

_ArrayCreate("53","55","63","64","Sky"), _

_ArrayCreate("235","53","250","67","Sky"), _

_ArrayCreate("204","56","222","70","Hev") _

)

Func _teleport()

MouseMove(116,370)

Sleep(100)

MouseDown("left")

Sleep(100)

MouseUp("left")

Sleep(100)

MouseMove(132,448)

Sleep(100)

MouseDown("left")

Sleep(100)

MouseUp("left")

Sleep(100)

Send("{ENTER}")

Sleep(100)

Send("{TAB}")

Sleep(100)

;Setting Teleport locs and Teleporting to starting Location

;Setting the X Axis

Send("{NUMPAD0}") ;Starting at 0

Sleep(100)

$XStart= $Plex[1][1]

For $i = 0 to $XStart Step 1

Send("{DOWN}")

Next

Send("{TAB}")

;Setting Y Teleport Axis

Send("{NUMPAD0}") ;Starting at 0

Sleep(100)

$YStart = $Plex[1][2]

For $i = 0 to $YStart Step 1

Send("{DOWN}")

Next

Send("{TAB}")

Sleep(100)

Send("{ENTER}")

Sleep(3500)

EndFunc

clicker.au3

Share this post


Link to post
Share on other sites
steveR

Well the help file reads: "When creating arrays you are limited to up to 64 dimensions and/or a total of 16 million element"

The help file on _ArrayCreate states: "Arrays up to 21 elements are supported"

so i don't know it that is the problem. Maybe it's because the subscripts are arrays themselves. Maybe _ArrayCreate() doesnt't support that. I'm not the best at arrays, so I'm not sure what could be wrong.


AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.

Share this post


Link to post
Share on other sites
Wylim

When I decrease my arrays size to this:

$Plex = _ArrayCreate("154","59","167","70", "Hel")

The array works fine. But I can't figure out how the program would assume that an array with 1 extra dimension x5 would throw it over the 21 limit. Any suggestions would be appreciate or any help with this matter.

I have also found with _arraydisplay that it doesn't display any of the arrays information. I am begining to think the AutoIt was never setup to handle multidimensional arrays at all.

If anyone knows anything about this any information would help.

Edited by Wylim

Share this post


Link to post
Share on other sites
steveR

Well i ran your code, i'm not sure what it was supposed to do, but i didn't get any errors. It opened something up Visual Studio, and opened up my browser. I'm not going to run again because it starting messing with a script I had open LOL.


AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.

Share this post


Link to post
Share on other sites
steveR

#include <array.au3>

$Plex = _ArrayCreate( _
_ArrayCreate("154","59","167","70", "Hel"), _ 
_ArrayCreate("86","165","95","184","Sur"), _ 
_ArrayCreate("156","69","171","73","Sur"), _ 
_ArrayCreate("269","0","298","29","Sur"), _ 
_ArrayCreate("278","126","289","130","Sur"), _
_ArrayCreate("0","0","58","8","Sky"), _ 
_ArrayCreate("0","10","8","18","Sky"), _
_ArrayCreate("53","55","63","64","Sky"), _
_ArrayCreate("235","53","250","67","Sky"), _
_ArrayCreate("204","56","222","70","Hev") _
)

_ArrayDisplay($plex, @error)

@error = 0 = no error

$Plex = _ArrayCreate("154","59","167","70", "Hel")
_ArrayDisplay($plex, @error)

works, so i guess it because of the nested _ArrayCreate() s

Edited by steveR

AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.

Share this post


Link to post
Share on other sites
steveR

I really don't know much about handeling arrays, so this might not be what you're looking for, but i didn't get any errors with this:

#include <array.au3>

$plex1 = StringSplit("154,59,167,70,Hel",",")
$Plex2 = StringSplit("86,165,95,184,Sur",",")

dim $plex3[2]
$plex3[0] = $plex1
$plex3[1] = $plex2
_ArrayDisplay($plex1, @error)
_ArrayDisplay($plex2, @error)
_ArrayDisplay($plex3[0], @error)
_ArrayDisplay($plex3[1], @error)

AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.

Share this post


Link to post
Share on other sites
Wylim

Yah I think I've found that AutoIt does not support Multidimensional Arrays. It would be nice if AutoIt in it's next version did have that capability. That to me really would set this program apart and would also allow me to better automate more programs and decrease the size of the programs.

Thanks,

Wylim

Share this post


Link to post
Share on other sites
steveR

how about this:

#include <array.au3>

$plex1 = StringSplit("154,59,167,70,Hel",",")
$Plex2 = StringSplit("86,165,95,184,Sur",",")
$plex3 = StringSplit("154,59,167,70,Hel",",")
$Plex4 = StringSplit("86,165,95,184,Sur",",")

dim $plex5[2][2] 
$plex5[0][0] = $plex1
$plex5[0][1] = $plex2
$plex5[1][0] = $plex3
$plex5[1][1] = $plex4
Edited by steveR

AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.

Share this post


Link to post
Share on other sites
Valik

Yah I think I've found that AutoIt does not support Multidimensional Arrays. It would be nice if AutoIt in it's next version did have that capability. That to me really would set this program apart and would also allow me to better automate more programs and decrease the size of the programs.

Thanks,

Wylim

<{POST_SNAPBACK}>

I suggest you keep digging if you think that. AutoIt quite happily supports multi-dimensional arrays. In fact, it can create more dimensions than the human brain can reasonably track (Which is only like 4 or 5 anyway...). You are using a user-created function which may or may not support what you are trying to do. I think that code looks a bit... errr... poor with all the nested calls and such. I expect that to be terribly inefficient (provided it was working). If you wish to work with multi-dimensional arrays, I'd say your best bet is to write your own functions to handle them for your specific needs. Although AutoIt does support multi-dimensional arrays, there is a limitation that they are hard to work with dynamically; meaning, the number of dimensions must be known at compile time as run-time discovery is difficult to achieve.

steveR, what you are doing isn't quite the same as a multi-dimensional array. You're storing an array inside an element of another array. That's a bug turned feature because many found it useful. It requires an extra step to extract the array out to a new variable so that it can be properly indexed. I don't think that's quite what the OP had in mind.

Share this post


Link to post
Share on other sites
steveR

steveR, what you are doing isn't quite the same as a multi-dimensional array. You're storing an array inside an element of another array. That's a bug turned feature because many found it useful. It requires an extra step to extract the array out to a new variable so that it can be properly indexed. I don't think that's quite what the OP had in mind.

Can you give an example of a proper multidimensional array, so i can wrap my head around it?


AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.

Share this post


Link to post
Share on other sites
SlimShady

You can find one in the help file. Look in the index for Dim.

Meanwhile I'll show you 2 examples.

Example 1

Dim $MyArr[4][2][2]

$MyArr[0][0][0] = "some value"
$MyArr[0][0][1] = "some value"
$MyArr[0][1][0] = "some value"
$MyArr[0][1][1] = "some value"

$MyArr[1][0][0] = "some value"
$MyArr[1][0][1] = "some value"
$MyArr[1][1][0] = "some value"
$MyArr[1][1][1] = "some value"

$MyArr[2][0][0] = "some value"
$MyArr[2][0][1] = "some value"
$MyArr[2][1][0] = "some value"
$MyArr[2][1][1] = "some value"

$MyArr[3][0][0] = "some value"
$MyArr[3][0][1] = "some value"
$MyArr[3][1][0] = "some value"
$MyArr[3][1][1] = "some value"

Example 2

Dim $MyArr[4][2][2]
For $d_1 = 0 To 3
   For $d_2 = 0 To 1
      For $d_3 = 0 To 1
         $MyArr[$d_1][$d_2][$d_3] = 'value: $MyArr[' & $d_1 & '][' & $d_2 & '][' & $d_3 & ']'
      Next
   Next
Next

Share this post


Link to post
Share on other sites
Wylim

I appreciate the advice on this matter and I will begin looking into coding my own way of creating and working with arrays. I will also start digging through the forums to see if anyone else has created there own form of handleing Multidimensional arrays through AutoIt. Until Then I will try to get this post active and put any updates or information I find on this subject here.

Thank you everyone for your help and I will continue trying to develop a way for AutoIt to be able to handle Multidimensional arrays in an attequate form.

I suppose I should note that this program was designed to work with Microsoft Internet Explorer so if you do not have this program installed I'm not sure what program it may attempt to open and operate with. After I have this program functional I will work on making it portable.

Edited by Wylim

Share this post


Link to post
Share on other sites
everseeker

I will continue trying to develop a way for AutoIt to be able to handle Multidimensional arrays in an attequate form.

Grin

You go guy....

/Grin


Everseeker

Share this post


Link to post
Share on other sites
GEOSoft

Grin

You go guy....

/Grin

Did you happen to notice that you just replied to a thread that is on the verge of being 3 years old?? A lot has happened with AutoIt in those 3 years.

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!"

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.