Sign in to follow this  
Followers 0
WeMartiansAreFriendly

_ArraySlice()

1 post in this topic

#1 ·  Posted (edited)

what it does is slices array, from $nBegin, to $nEnd, like the javascript function.. it's similar to arraydelete()

$nBegin cuts all the values from the begining, if it is 3, then 0,1,2, would be cut off.

$nEnd has to be smaller than the arrays total amount, but you can also use a negative value to cut off, for instance the last 2 parts of the array. if it was 4 then 5,6,7.. all the way to the max array would be cut off. if $nEnd is 0 then just the $nBegin will be cut off

Local $piArr[8] = [7, 'ahoy','arr', 'mate','treasure', 'ye be','gold','poopdeck']

_ArraySlice($piArr, 2, -2)


For $x = 1 to UBound($piArr)-1
    msgbox(0,'',$piArr[$x] & @LF)
Next

Func _ArraySlice(ByRef $avArray, $nBegin, $nEnd)
    Local $iSize, $nvArray[1], $n = 1, $y = 0
    If Not IsArray($avArray) Then
        Return SetError(1,0,$avArray)
    EndIf
    $iSize = UBound($avArray)-1
    If $nBegin < 0 Or  $nEnd < $nBegin Or $nEnd > $iSize Then SetError(1,0,$avArray)
    If $nEnd <= 0 Then $nEnd = Execute($iSize + $nEnd) 
    If $nBegin = 0 Then $n = 0
    For $i = $n To $iSize
        If $i >= $nBegin And $i <= $nEnd Then
            $y += 1
            ReDim $nvArray[$y + 1]
            $nvArray[$y] = $avArray[$i] 
        EndIf
    Next
    $avArray = $nvArray
    Return 1
EndFunc

note: doesnt look like much i spent a painstaking amount of time on this stupid function! im so proud of myself finally got it working.. $#!@ >:P:whistle:

Edited by mrRevoked

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

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