Jump to content

Recommended Posts

Posted (edited)

Right this is my first time using arrays, I have created a 2D array

#include <Array.au3>

Local $a2DArray[3][2] = [ _
['text1', 'answer1'], _
['text2', 'answer2'], _
['text1', 'answer2']]

_ArrayDisplay($a2DArray, "2D display") ;

What I was to do is pull out the data from row 0 column 0 to a variable $loc and data from row 0 column 1 to variable $ans

Then run that through a function like:

Func check()
local $Aloc = $loc
local $Aans = $ans

If $Aloc = "text1" & $Aans = "answer1" then
   msgbox(4096,"Success","Answer was test1")
Else
   msgbox(4096,"Fail","Answer Failed Check"
Endif

EndFunc ;==>check

then it needs to do it all again for the next row and so on

Can anyone point me in the right direction?

Edited by cookiemonster
Posted

For $iIndex = 0 to UBound(a2DArray, 1) - 1
    check($a2DArray[$iIndex][0], $a2DArray[$iIndex][1])
Next

Func check($Aloc, $Aans)

    If $Aloc = "text1" & $Aans = "answer1" then
       msgbox(4096,"Success","Answer was test1")
    Else
       msgbox(4096,"Fail","Answer Failed Check")
    Endif

EndFunc ;==>chec

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

I have tried that so the total script is:

#include <Array.au3>

Local $a2DArray[3][2] = [ _
['text1', 'answer1'], _
['text2', 'answer2'], _
['text1', 'answer2']]

_ArrayDisplay($a2DArray, "2D display") ; 

For $iIndex = 0 to UBound($a2DArray, 1) - 1
    check($a2DArray[$iIndex][0], $a2DArray[$iIndex][1])
Next

Func check($Aloc, $Aans)

    If $Aloc = "text1" & $Aans = "answer1" then
       msgbox(4096,"Success","Answer was test1")
    Else
       msgbox(4096,"Fail","Answer Failed Check")
    Endif

EndFunc ;==>chec

However the first row of the array should come back with the message box "Success" "Answer was test1" but it doesnt, it comes back with the fail message box, any ideas?

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
×
×
  • Create New...