Jump to content

Recommended Posts

Posted

Hi guys

I have 3 arrays

Local $1[4] = [315,275,366,254]
Local $2[4] = [345,298,430,265]
Local $3[4] = [485,485,470,275]

And would like to use the elements like this

For $x = 1 to 3

$sum = $x[0]
$sum2 = $x[1]
$sum3 = $x[2]
$sum4 = $x[3]

; do something else here with the above 4 results, then continue

Next

What is the correct way to format it as the above doesn't work, thanks

Posted

Just copy the variable to known temp:

#include <Array.au3> ; Only for _ArrayDisplay()

Local $1[4] = [315, 275, 366, 254]
Local $2[4] = [345, 298, 430, 265]
Local $3[4] = [485, 485, 470, 275]

For $x = 1 To 3
    $aTemp = Eval($x)
    _ArrayDisplay($aTemp, $x & ": $aTemp")
Next

:mellow:

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
Posted

Hi JohnOne

Yes that makes sense but not what I need

$sum = $1[0]

$sum2 = $1[1]

$sum3 = $1[2]

$sum4 = $1[3]

on the first pass then

$sum = $2[0]

$sum2 = $2[1]

$sum3 = $2[2]

$sum4 = $2[3]

and so on, does that make sense?

  • Moderators
Posted

Phaser,

You could perhaps use Eval, Assign and Execute to fudge up something, but it would be much easier to do this: :P

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $aArray[3][4] = [[315, 275, 366, 254], [345, 298, 430, 265], [485, 485, 470, 275]]

For $x = 0 To 2

    $sum = $aArray[$x][0]
    $sum2 = $aArray[$x][1]
    $sum3 = $aArray[$x][2]
    $sum4 = $aArray[$x][3]

    ConsoleWrite($sum & " - " & $sum2 & " - " & $sum3 & " - " & $sum4 & @CRLF)

    ; do something else here with the above 4 results, then continue

Next

I hope that helps. :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (edited)

Hi,

my solution with your 3 origin arrays. Depends what you want, you may prefer Melba's solution.

Local $1[4] = [315,275,366,254]
Local $2[4] = [345,298,430,265]
Local $3[4] = [485,485,470,275]

$run = 1
_mysum ($1)
_mysum ($2)
_mysum ($3)

Func _mysum ($array)
    $sum = $array [0]
    $sum1 = $array [1]
    $sum2 = $array [2]
    $sum3 = $array [3]
    MsgBox (0, "Sum Run " & $run, $sum & @CRLF & $sum1 & @CRLF &  $sum2 & @CRLF & $sum3)
    $run += 1
EndFunc

;-))

Stefan

@Melba23: HaHaHaHaHa, thanks ....

Edited by 99ojo
  • Moderators
Posted

99ojo,

Nice lateral thinking - Edward de Bono would be proud of you! :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...