Jump to content

Dimensional arrays


Recommended Posts

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

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

What 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

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

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 by mdiesel
Link to comment
Share on other sites

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 script

8)

NEWHeader1.png

Link to comment
Share on other sites

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

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 by Authenticity
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...