Jump to content
Sign in to follow this  
morgalis

Dimensional arrays

Recommended Posts

morgalis

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

Share this post


Link to post
Share on other sites
martin

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.

Share this post


Link to post
Share on other sites
morgalis

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

Share this post


Link to post
Share on other sites
Mat

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

Share this post


Link to post
Share on other sites
Valuater

I posted on the other thread...

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Mat

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.

Share this post


Link to post
Share on other sites
Valuater

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

Share this post


Link to post
Share on other sites
Valuater

;) better now? :(

Much!! ^_^

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
morgalis

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?

Share this post


Link to post
Share on other sites
Authenticity

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

Share this post


Link to post
Share on other sites
morgalis

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

Share this post


Link to post
Share on other sites
Authenticity

Maybe somewhere in the code you're doing something that change the $Waypoints variable. Can you post more code please?

Edited by Authenticity

Share this post


Link to post
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
Sign in to follow this  

×