Jump to content

_ArrayPush UDF does not return expected values


AnnA
 Share

Recommended Posts

First time having to ask something that I could not find after enough searching through the forums.

I was under the impression that the result of Func _ArrayPush(ByRef $avArray, $sValue, $i_Direction = 1) will be $sValue at the location $avArray[0] and each original value from $avArray[0] to $avArray[2nd last] will be moved up one position.

e.g. Array with 1,2,3,4,5 --- Push 8 with direction 1 will result in 8,1,2,3,4

Currently it returns 8,2,3,4,5

In the UDF the line is :-

"For $i = (UBound($avArray) - 1) To 1"

Shouldn't it be

"For $i = (UBound($avArray) - 1) To 1 Step -1"

for the loop to be effective at all?

-I'm sorry if this is a stupid question but the help file says

"A For loop will execute zero times if:

start > stop and step >= 0"

-AnnA

Link to comment
Share on other sites

  • Developers

First time having to ask something that I could not find after enough searching through the forums.

I was under the impression that the result of Func _ArrayPush(ByRef $avArray, $sValue, $i_Direction = 1) will be $sValue at the location $avArray[0] and each original value from $avArray[0] to $avArray[2nd last] will be moved up one position.

e.g. Array with 1,2,3,4,5 --- Push 8 with direction 1 will result in 8,1,2,3,4

Currently it returns 8,2,3,4,5

In the UDF the line is :-

"For $i = (UBound($avArray) - 1) To 1"

Shouldn't it be

"For $i = (UBound($avArray) - 1) To 1 Step -1"

for the loop to be effective at all?

-I'm sorry if this is a stupid question but the help file says

"A For loop will execute zero times if:

start > stop and step >= 0"

-AnnA

Sounds like you found a BUG in the _ArrayPush() UDF. Will update it in the next release....

Thanks

:P

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...