Sign in to follow this  
Followers 0
erezlevi

Array changes help needed

3 posts in this topic

hi,

I am having problems with an Array. the Array contains many Elements that I want out of my Array, like from elemet $Array[1] till $Array[23], but those Elements are reapting in the whole Array several times. what I do know is that Element $Array[24] one after the 23 that I need to erase allways start with : "Switch Name" ,

so I am using the following:

_FileReadToArray ("c:\erez1.txt",$EREZ)
_ArrayDisplay ($EREZ)
$E1=_ArraySearch ($EREZ,"Switch Name",0,0,1,1)

now, $E1 holds where the First "Switch Name" is encountered in the first time, I need to delete all Array-element before, like if the $E1 return 46, I need to bring "up" the Array so Array[46] will be Array[1] now. Meaning that all previous 46 are deleted and the Array starts with the word "Switch Name". the second time "Switch Name" is encountered I need it to bring it up only 2 times, so if $E1 in the second time is at "60" position then it swap to "58" position and delets 59 position.

I thought of using "_Arrayswap" but I can't it won't do the job, you can only swap 2 elements, I thought of using _ArrayToString, but it is too difficult doing this in a string and I want it to be done in the Array itself.

Any Ideas?

Share this post


Link to post
Share on other sites



OK, problem solved!

here is the solution code:

$E1=16; it changes all the time... but here it will be 16... :) 
for $b=0 to 16
_ArraySwap ($EREZ[$E1+$b],$EREZ1[$b+1])
Next
For $b=16 to 24
_Arrayswap ($EREZ[$E1+16+($b-5)],$EREZ1[$b+2])
Next
For $b=24 to 31
_Arrayswap ($EREZ[$E1+16+($b+6)],$EREZ1[$b+3])
Next
$EREZ2=$EREZ1
$r=$EREZ2[0]

there is only one problem with it, JOS maybe you can help here because I don't know why it happens, The $EREZ2[0]= nothing, meaning after taking everything I need from Array "EREZ" to "EREZ1" AutoIT doesn't know what is the Array Dimentions. maybe a BUG with _Arrayswap?

never the less I attached two .txt files - one is erez1.txt which holds the scrampled TCP captured telnet data, and the second is after applying a hole lot of code to fix it - erez3.txt

I still wants to know why EREZ2[0] = nothing ... anybody, JOS please???

Share this post


Link to post
Share on other sites

hi,

found out! only _filereadtoArray is giving this: (help file)

Remarks

$aArray[0] will contain the number of records read into the array.

but why? why not all arrays hold the number of filled lines within it? feature request....

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  
Followers 0