antmar904 Posted December 7, 2017 Posted December 7, 2017 Hi I'm trying to create a 2D Array with a file that is TAB delimited but can't figure out how. File Content: abcd <tab> 1234 asdf <tab> dfsa aetg <tab> adfa #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Check() Func Check() Local $ArraryList Local $File = @ScriptDir & "\LocalAdminRem12072017.txt" Local $Array = _FileReadToArray($File, $ArraryList, "", @TAB) _ArrayDisplay($Array) EndFunc
SlackerAl Posted December 7, 2017 Posted December 7, 2017 #include <Array.au3> #include <File.au3> Check() Func Check() Local $ArraryList Local $Array = _FileReadToArray("test.txt", $ArraryList, 4, @TAB) _ArrayDisplay($ArraryList, "2D display") EndFunc Problem solving step 1: Write a simple, self-contained, running, replicator of your problem.
antmar904 Posted December 7, 2017 Author Posted December 7, 2017 (edited) 2 minutes ago, SlackerAl said: #include <Array.au3> #include <File.au3> Check() Func Check() Local $ArraryList Local $Array = _FileReadToArray("test.txt", $ArraryList, 4, @TAB) _ArrayDisplay($ArraryList, "2D display") EndFunc I've also tried that and the script just runs then closes without any errors: #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Check() Func Check() Local $ArraryList[1] Local $File = @ScriptDir & "\LocalAdminRem12072017.txt" Local $Array = _FileReadToArray($File, $ArraryList, 4, @TAB) _ArrayDisplay($Array, "Arrary") EndFunc SciTE output: >Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\usa\Documents\Altiris\RemAdmin\RemAdminRem.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop +>10:47:02 AutoIt3.exe ended.rc:0 +>10:47:02 AutoIt3Wrapper Finished. >Exit code: 0 Time: 0.966 Edited December 7, 2017 by antmar904
antmar904 Posted December 7, 2017 Author Posted December 7, 2017 (edited) Oops, I see what I did wrong I was calling the wrong variable. This is working now: #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Check() Func Check() Local $ArraryList Local $File = @ScriptDir & "\LocalAdminRem12072017.txt" MsgBox(0, "", $File) Local $Array = _FileReadToArray($File, $ArraryList, 4, @TAB) _ArrayDisplay($ArraryList, "Arrary") EndFunc Edited December 7, 2017 by antmar904
antmar904 Posted December 7, 2017 Author Posted December 7, 2017 (edited) How do I display only column one or only column two in the array? How would I specify the different columns in a 2D array? #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Check() Func Check() Local $ArrayList[2] Local $File = @ScriptDir & "\LocalAdminRem12072017.txt" ;MsgBox(0, "", $File);debug Local $Array = _FileReadToArray($File, $ArrayList, 4, @TAB) _ArrayDisplay($ArrayList, "Arrary") For $i = 0 To $ArrayList - 1 MsgBox(0, "", $ArrayList[$i]);show each row in the first column of the array. Next EndFunc Edited December 7, 2017 by antmar904
antmar904 Posted December 7, 2017 Author Posted December 7, 2017 4 minutes ago, antmar904 said: How do I display only column one or only column two in the array? How would I specify the different columns in a 2D array? #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Check() Func Check() Local $ArrayList[2] Local $File = @ScriptDir & "\LocalAdminRem12072017.txt" ;MsgBox(0, "", $File);debug Local $Array = _FileReadToArray($File, $ArrayList, 4, @TAB) _ArrayDisplay($ArrayList, "Arrary") For $i = 0 To $ArrayList - 1 MsgBox(0, "", $ArrayList[$i]);show each row in the first column of the array. Next EndFunc I figured it out #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Check() Func Check() Local $ArrayList Local $File = @ScriptDir & "\LocalAdminRem12072017.txt" ;MsgBox(0, "", $File);debug Local $Array = _FileReadToArray($File, $ArrayList, 4, @TAB) _ArrayDisplay($ArrayList, "Array") For $i = 0 To UBound($ArrayList) - 1 MsgBox(0, "", $ArrayList[$i][0]);show each row in the first column of the array Next EndFunc
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