Jump to content

Break an array into multiple lines of code


Go to solution Solved by jdelaney,

Recommended Posts

Posted

I wanted to organize my code a bit to make it easier to setup and understand later. Would anyone know how to break an array into multiple lines of code

For example I didn't want to do it in one line as shown here

Dim $aEmployee[3][2] = [["Employee0","Employee Info 0"],["Employee1","Employee Info 1"],["Employee2","Employee Info 2"]]

I wanted to group them by employee something like this

$aEmployee[0]=["Employee 0","Employee Info 0"]

$aEmployee[1]=["Employee 1","Employee Info 1"]

$aEmployee[2]=["Employee 2","Employee Info 2"]

This way each line has it's own employee information.

 

Thanks again for any answers

Posted (edited)

Do you mean something like this? (Might a recommend looking into the use of an ini File? Through ignorance of what exactly your program is to accomplish, this is just a shot in the dark. If this isn't what your looking for, just say so.)

#include <Array.au3>

Local $EmployeeOne[2] = ["Andreu", "His Info"]
Local $EmployeeTwo[2] = ["That Guy", "His Info"]
_ArrayDisplay($EmployeeOne)
_ArrayDisplay($EmployeeTwo)

Edit:

Also, if you have already set up ALL of your data into arrays like this... There are ways to automate the process of re-writing it in the case there is a lot of it :).

Edited by Andreu
Posted

Here's another try. If this still isn't what your looking for, give me an example of something you've tried... that didn't work / doesn't quite do what you want.... And I will have something to base off of.

#include <Array.au3>

Local $EmployeeOne[4][3]
$EmployeeOne[0][0] = "Name"
$EmployeeOne[0][1] = "Employee ID"
$EmployeeOne[0][2] = "Hire Date"

$EmployeeOne[1][0] = "Andreu"
$EmployeeOne[1][1] = "61511"
$EmployeeOne[1][2] = "Nov 28, 2010"

$EmployeeOne[2][0] = "Nassausky"
$EmployeeOne[2][1] = "80650"
$EmployeeOne[2][2] = "Jun 19, 2013"

$EmployeeOne[3][0] = "Jon"
$EmployeeOne[3][1] = "1"
$EmployeeOne[3][2] = "Oct 1, 1998"


_ArrayDisplay($EmployeeOne)
  • Solution
Posted (edited)

#include <Array.au3>
Local $aEmployee[3][2] = [ _
    ["Employee0","Employee Info 0"], _
    ["Employee1","Employee Info 1"], _
    ["Employee2","Employee Info 2"]]
_ArrayDisplay($aEmployee)
#include <Array.au3>

Local $aEmployee_1[2] = ["Employee0","Employee Info 1"]
Local $aEmployee_2[2] = ["Employee1","Employee Info 2"]
Local $aEmployee_3[2] = ["Employee2","Employee Info 3"]

Local $aEmployees[3] = [$aEmployee_1,$aEmployee_2,$aEmployee_3]

For $i = 0 To UBound($aEmployees)-1
    _ArrayDisplay($aEmployees[$i])
Next



#include <Array.au3>

Local $aEmployee_1[2] = ["Employee0","Employee Info 1"]
Local $aEmployee_2[2] = ["Employee1","Employee Info 2"]
Local $aEmployee_3[2] = ["Employee2","Employee Info 3"]

Local $aEmployees[3] = [$aEmployee_1,$aEmployee_2,$aEmployee_3]

;~ For $i = 0 To UBound($aEmployees)-1
;~  _ArrayDisplay($aEmployees[$i])
;~ Next

; or...but more 'dangerous' than the above
$i = 1
While True
    $aTemp = Eval("aEmployee_" & $i)
    If Not IsArray($aTemp) Then ExitLoop
    _ArrayDisplay($aTemp)
    $i+=1
WEnd



Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Posted

Thanks All,  I might use your option Andreu.   I actually figured out the code jdelaney left as his first option and separating the lines with the underscore. 

You all are very helpful.  I just about have what I need to which will be a basic toolbar which sends keys to my timeclock application..

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...