Sign in to follow this  
Followers 0
kart442

_ArrayAdd (Can't get it to work..)

3 posts in this topic

#1 ·  Posted (edited)

I want to add to the $colorADD from the $color array as it loops each time

until $colorADD has 64 elements.

#include <Array.au3>
#include <File.au3>
Dim $color[64]
Dim $colorADD[64]
Dim $xa[64]
Dim $xy[64]
$file1 = "F:4\xy.au3" 
_FileReadToArray($file1, $xa)
If @error Then
    MsgBox(0, "Error", "Error reading " & $xa)
EndIf
;~ While 1
For $i = 1 To $xa[0]
    $Line = $xa[$i]
    $xy = StringSplit($Line, " ", 1)
    $x = $xy[1]
    $y = $xy[2]
    $xr1 = $x + 53
    $xr2 = $xr1 + 53
    $xr3 = $xr2 + 53
    $xr4 = $xr3 + 53
    $xr5 = $xr4 + 53
    $xr6 = $xr5 + 53
    $xr7 = $xr6 + 53
    $yu1 = $y - 53
    $yu2 = $yu1 - 53
    $yu3 = $yu2 - 53
    $yu4 = $yu3 - 53
    $yu5 = $yu4 - 53
    $yu6 = $yu5 - 53
    $yu7 = $yu6 - 53
;~  _ArrayDisplay($xy)

    $color = _ArrayCreate(PixelGetColor($x, $y))
    _ArrayDisplay($color)
    $colorADD = _ArrayCreate($color)
_ArrayAdd($colorADD, $color)
_ArrayDisplay($colorADD)
Next
Edited by kart442

Share this post


Link to post
Share on other sites



Not sure why you would need 2 arrays to hold the same thing

#include <Array.au3>
#include <File.au3>
Dim $color
Dim $colorADD
Dim $xa[64]
Dim $xy[64]
$file1 = "F:4\xy.au3"
_FileReadToArray($file1, $xa)
If @error Then
    MsgBox(0, "Error", "Error reading " & $xa)
EndIf
;~ While 1
For $i = 1 To $xa[0]
    $Line = $xa[$i]
    $xy = StringSplit($Line, " ", 1)
    $x = $xy[1]
    $y = $xy[2]
    $xr1 = $x + 53
    $xr2 = $xr1 + 53
    $xr3 = $xr2 + 53
    $xr4 = $xr3 + 53
    $xr5 = $xr4 + 53
    $xr6 = $xr5 + 53
    $xr7 = $xr6 + 53
    $yu1 = $y - 53
    $yu2 = $yu1 - 53
    $yu3 = $yu2 - 53
    $yu4 = $yu3 - 53
    $yu5 = $yu4 - 53
    $yu6 = $yu5 - 53
    $yu7 = $yu6 - 53
;~  _ArrayDisplay($xy)
    If IsArray($colorADD) Then
        _ArrayAdd($colorADD, PixelGetColor($x, $y))
    Else
        $colorADD = _ArrayCreate(PixelGetColor($x, $y))
    EndIf
    _ArrayDisplay($colorADD)
Next

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Not sure why you would need 2 arrays to hold the same thing

#include <Array.au3>
#include <File.au3>
Dim $color
Dim $colorADD
Dim $xa[64]
Dim $xy[64]
$file1 = "F:4\xy.au3"
_FileReadToArray($file1, $xa)
If @error Then
    MsgBox(0, "Error", "Error reading " & $xa)
EndIf
;~ While 1
For $i = 1 To $xa[0]
    $Line = $xa[$i]
    $xy = StringSplit($Line, " ", 1)
    $x = $xy[1]
    $y = $xy[2]
    $xr1 = $x + 53
    $xr2 = $xr1 + 53
    $xr3 = $xr2 + 53
    $xr4 = $xr3 + 53
    $xr5 = $xr4 + 53
    $xr6 = $xr5 + 53
    $xr7 = $xr6 + 53
    $yu1 = $y - 53
    $yu2 = $yu1 - 53
    $yu3 = $yu2 - 53
    $yu4 = $yu3 - 53
    $yu5 = $yu4 - 53
    $yu6 = $yu5 - 53
    $yu7 = $yu6 - 53
;~  _ArrayDisplay($xy)
    If IsArray($colorADD) Then
        _ArrayAdd($colorADD, PixelGetColor($x, $y))
    Else
        $colorADD = _ArrayCreate(PixelGetColor($x, $y))
    EndIf
    _ArrayDisplay($colorADD)
Next
If I could get array $color to "add" the new element for each loop and keep the previous element also that would be great....Can you help?

Didn't notice the changes you made at first...Thanks, but now how to get it to stop at 64 elements then start over "empty".

Edited by kart442

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