morgalis Posted May 5, 2009 Posted May 5, 2009 reading out a file i have diferent waypoints. These i wanna insert into a array dimensional like Waypoint [$i] = StringBetween($line,'t>','</') this is the content of the file: <Waypoint>6782.96 198.47</Waypoint> <Waypoint>6793.25 202.39</Waypoint> <Waypoint>6802.33 208.82</Waypoint> <Waypoint>6812.63 213.29</Waypoint> <Waypoint>6821.05 218.73</Waypoint> <Waypoint>6829.41 224.29</Waypoint> <Waypoint>6837.23 232.18</Waypoint> result shoud be $Waypoint [1][1]=6782.96 $Waypoint[1][2]=198.47 What would be the best routine/logic to do so ? thnx
Mat Posted May 5, 2009 Posted May 5, 2009 (edited) wrong forum but: $sTest = StringSplit (StringStripCR ($sWhole), @LF) MsgBox (0, "", $sTest[0]) Dim $aArray[$sTest[0] + 1][2] $aArray[0][0] = $sTest[0] For $i = 1 to $sTest[0] $aTest = StringSplit (StringTrimRight (StringTrimLeft ($sTest[$i], 10), 11), " "); Splits by space. $aArray[$i][0] = $aTest[1] $aArray[$i][1] = $aTest[2] Next Edited May 5, 2009 by mdiesel AutoIt Project Listing
Valuater Posted May 5, 2009 Posted May 5, 2009 This works... #include <Array.au3> $sWhole = "<Waypoint>6782.96 198.47</Waypoint>" & @CRLF & _ "<Waypoint>6793.25 202.39</Waypoint>" & @CRLF & _ "<Waypoint>6802.33 208.82</Waypoint>" & @CRLF & _ "<Waypoint>6812.63 213.29</Waypoint>" & @CRLF & _ "<Waypoint>6821.05 218.73</Waypoint>" & @CRLF & _ "<Waypoint>6829.41 224.29</Waypoint>" & @CRLF & _ "<Waypoint>6837.23 232.18</Waypoint>" $sTest = StringSplit(StringStripCR($sWhole), @LF) Dim $aArray[$sTest[0]][2] For $i = 1 To $sTest[0] - 1 $aTest = StringSplit($sTest[$i], " "); Splits by space. $aArray[$i][0] = StringReplace($aTest[1], "<Waypoint>", "") $aArray[$i][1] = StringReplace($aTest[2], "</Waypoint>", "") Next _ArrayDisplay($aArray) 8)
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