morgalis Posted May 5, 2009 Share Posted May 5, 2009 i have a file with this content: <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> <Waypoint>6842.46 243.42</Waypoint> <Waypoint>6847.15 252.29</Waypoint> <Waypoint>6853.42 263.12</Waypoint> I would like to read this file and insert it in an array: $Waypoint[1][1]= 6782.96 $Waypoint[1][2]= 198.47 and so on , what would be the best logic to do so , i dont know from beginning how many waypoint the file contains , should i use Ubound ? Please an example thnx for your time Link to comment Share on other sites More sharing options...
martin Posted May 5, 2009 Share Posted May 5, 2009 i have a file with this content: <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> <Waypoint>6842.46 243.42</Waypoint> <Waypoint>6847.15 252.29</Waypoint> <Waypoint>6853.42 263.12</Waypoint> I would like to read this file and insert it in an array: $Waypoint[1][1]= 6782.96 $Waypoint[1][2]= 198.47 and so on , what would be the best logic to do so , i dont know from beginning how many waypoint the file contains , should i use Ubound ? Please an example thnx for your timeWhat have you tried so far and what have you looked up? What part of what you looked up did you not understand, or what happened that you did not expect when you tried something? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
morgalis Posted May 5, 2009 Author Share Posted May 5, 2009 Ok the stringsplit automatecly creates me an array ,so far is ok , but at the same time the variable $line need to be inserted in an array too. now i cant figure out that part , coz i dont know how much lines the file will have. so an example would be nice Link to comment Share on other sites More sharing options...
Mat Posted May 5, 2009 Share Posted May 5, 2009 (edited) I posted one in your other thread in example scripts. $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 please don't multi thread, autoit doesn't use this functionality. the code is not perfect, and Thge first line does not always work, use a more accurate one like _FileGetLines. Edited May 5, 2009 by mdiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
Valuater Posted May 5, 2009 Share Posted May 5, 2009 I posted on the other thread... 8) Link to comment Share on other sites More sharing options...
Mat Posted May 5, 2009 Share Posted May 5, 2009 My post on the other thread is wrong - I forgot to remove the <WAYPOINTS>, its now been done. The only difference between mine and valuaters is that the removing of the tags is in a different place. AutoIt Project Listing Link to comment Share on other sites More sharing options...
Valuater Posted May 5, 2009 Share Posted May 5, 2009 My post on the other thread is wrong - I forgot to remove the <WAYPOINTS>, its now been done. The only difference between mine and valuaters is that the removing of the tags is in a different place.You might want to look again, or just test your script8) Link to comment Share on other sites More sharing options...
Mat Posted May 5, 2009 Share Posted May 5, 2009 better now? AutoIt Project Listing Link to comment Share on other sites More sharing options...
Valuater Posted May 5, 2009 Share Posted May 5, 2009 better now? Much!! 8) Link to comment Share on other sites More sharing options...
morgalis Posted May 6, 2009 Author Share Posted May 6, 2009 Did some tests but both not working . Now i declared this Global $Waypoints[0][2] in a function i have this: Case $keyword = "Waypoint" ;select waypoints $Snag = StringBetween($line,'t>','</') $xyz = StringSplit($Snag, " ") $Waypoints[1][1] = $xyz[1] $Waypoints[1][2] = $xyz[2] (92) : ==> Expected a "=" operator in assignment statement.: $Waypoints[1][1] = $xyz[1] $Waypoints^ ERROR what i am doing wrong? Link to comment Share on other sites More sharing options...
Authenticity Posted May 6, 2009 Share Posted May 6, 2009 (edited) Try it like this: Global $Waypoints[1][2] ; [0][2] is not valid. ; ...in a function i have this: ; ... Case $keyword = "Waypoint" ;select waypoints $Snag = StringBetween($line,'t>','</') $xyz = StringSplit($Snag, " ") $Waypoints[0][0] = $xyz[1] ; Subscript is zero-based. $Waypoints[0][1] = $xyz[2] ; Same. Use code tags please. Edited May 6, 2009 by Authenticity Link to comment Share on other sites More sharing options...
morgalis Posted May 6, 2009 Author Share Posted May 6, 2009 Ok , did exactly the same $Waypoints[0][0] = $xyz[1]; $Waypoints[0][1] = $xyz[2]; (92) : ==> Expected a "=" operator in assignment statement.: $Waypoints[0][0] = $xyz[1] $Waypoints^ ERROR Link to comment Share on other sites More sharing options...
Authenticity Posted May 6, 2009 Share Posted May 6, 2009 (edited) Maybe somewhere in the code you're doing something that change the $Waypoints variable. Can you post more code please? Edited May 6, 2009 by Authenticity 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