Jack023 Posted November 9, 2013 Share Posted November 9, 2013 Hey all, I have some information in a textfile listed with: information1:information2 information3:information4 etc... now i want make a a dimensiol array array[0][0] then second line array[1][1]. This is possible i think? Could somebody help me , let we say the textfile is named: information.txt Thanks in advance Link to comment Share on other sites More sharing options...
Jack023 Posted November 9, 2013 Author Share Posted November 9, 2013 Can't edit it, but i want: array [0] is nothing Information1:information2 I want information1 in array[1] and ifirmation 2 in array[2] Information3:Information4 Informatiom3 in array[3] etc But not the ' : ' symbol All read from a textfile! Thanks in advance , Link to comment Share on other sites More sharing options...
Jfish Posted November 9, 2013 Share Posted November 9, 2013 Have you looked at this function? Do you have any code you could post? #include <File.au3> _FileReadToArray($sFilePath, ByRef $aArray) Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
jdelaney Posted November 9, 2013 Share Posted November 9, 2013 (edited) Here: #include <Array.au3> $sString = FileRead(@DesktopDir & "\some.txt") $aData = StringSplit($sString, @LF & ":") ; Remove @CR's For $i = 1 To UBound($aData) - 1 $aData[$i] = StringStripCR($aData[$i]) Next _ArrayDisplay($aData) Returns: [0]|4 [1]|information1 [2]|information2 [3]|information3 [4]|information4 Where desktop file = some.txt contains: information1:information2 information3:information4 Edited November 9, 2013 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. Link to comment Share on other sites More sharing options...
jdelaney Posted November 9, 2013 Share Posted November 9, 2013 or, returning a base 0 array: #include <Array.au3> $sString = FileRead(@DesktopDir & "\some.txt") ;~ $aData = StringSplit($sString, @LF & ":") ; Remove @CR's ;~ For $i = 1 To UBound($aData) - 1 ;~ $aData[$i] = StringStripCR($aData[$i]) ;~ Next ;~ _ArrayDisplay($aData) $aData = StringRegExp($sString,"[^:\v]+",3) _ArrayDisplay($aData) 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. Link to comment Share on other sites More sharing options...
Jack023 Posted November 10, 2013 Author Share Posted November 10, 2013 Perfect ! Thanks and i will look if i can complete it Link to comment Share on other sites More sharing options...
czardas Posted November 10, 2013 Share Posted November 10, 2013 (edited) Can be done with >_CSVSplit First read file and then pass the data to the function with the delimiter changed to colon. That's if you want a 2D array. I'm not sure what a a dimensiol array array is is. Maybe it's not what you want. Oops wrong function name - changed. Edited November 10, 2013 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
jchd Posted November 10, 2013 Share Posted November 10, 2013 I'm not sure what a a dimensiol array array is is. How do you call these pink pills in your area? Maybe it's not what you want. Sure! czardas 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
czardas Posted November 10, 2013 Share Posted November 10, 2013 (edited) How do you call these pink pills in your area? I don't know if I'm seeing double, or it's the pills. I mean: even the indices have been doubled. I thought the OP wanted a 2D array. Edited November 10, 2013 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Jack023 Posted November 10, 2013 Author Share Posted November 10, 2013 (edited) #include <Array.au3> ;array read $sString = FileRead(@DesktopDir & "\5faccs.txt") $aData = StringSplit($sString, @LF & ":") ; Remove @CR's For $i = 1 To UBound($aData) - 1 $aData[$i] = StringStripCR($aData[$i]) Next fixed it, only need help with my loop, but its a private script , so i dont want bring it in public! If someone can add me at skype: jack.jack023 i would really appreciate that ! Edited November 10, 2013 by Jack023 Link to comment Share on other sites More sharing options...
czardas Posted November 10, 2013 Share Posted November 10, 2013 (edited) Where did you put the message box? When the loop has finished, $i is greater than the maximum index of the array. If you also then add 1, $i will be greater by 2 counts. You should get an error about array dimension range exceeded. Put the msgbox inside the loop and do not add 1. Oh you deleted your question. Now my responce makes no sense. Edited November 10, 2013 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Jack023 Posted November 10, 2013 Author Share Posted November 10, 2013 well thats not the point, i fixed that but i don't want to put my whole script here what i mean if someone can add me 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