Phaser Posted May 28, 2010 Share Posted May 28, 2010 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 Link to comment Share on other sites More sharing options...
JohnOne Posted May 28, 2010 Share Posted May 28, 2010 I dont really understand what you need can you explain a little more Does this make any sense to you? $sum = $1[$x] $sum2 = $1[$x] $sum3 = $1[$x] $sum4 = $1[$x] AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 28, 2010 Share Posted May 28, 2010 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 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 More sharing options...
Phaser Posted May 28, 2010 Author Share Posted May 28, 2010 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? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 28, 2010 Moderators Share Posted May 28, 2010 Phaser,You could perhaps use Eval, Assign and Execute to fudge up something, but it would be much easier to do this: #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 NextI hope that helps. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
99ojo Posted May 28, 2010 Share Posted May 28, 2010 (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 May 28, 2010 by 99ojo Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 28, 2010 Moderators Share Posted May 28, 2010 99ojo,Nice lateral thinking - Edward de Bono would be proud of you! M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now