Sign in to follow this  
Followers 0
Jochem

extracting items from an array to a new array

5 posts in this topic

#1 ·  Posted (edited)

I want to delete all the entries that starts with xxxx or to extract all the entries that doesn`t start with xxxx.

so i thought that

_ArrayFindAll($aArray,"ws-c",0,0,0,1,0)
would do the tric but this is giving me just the rowindex :P

how can I solve this?

Edited by Jochem

Share this post


Link to post
Share on other sites



I want to delete all the entries that starts with xxxx or to extract all the entries that doesn`t start with xxxx.

so i thought that

_ArrayFindAll($aArray,"ws-c",0,0,0,1,0)
would do the tric but this is giving me just the rowindex :unsure:

how can I solve this?

Just loop through the array (in reverse, with Step -1) and _ArrayDelete() the unwanted elements.

:P


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Just loop through the array (in reverse, with Step -1) and _ArrayDelete() the unwanted elements.

:P

Func _sortarrayworkstations()
    $todelete = _ArraySearch($aComplist, "xxxx","","",0,1,0,0)
    For $element = 1 To $todelete Step -1
        _ArrayDelete($aCompList,$element)
    Next
EndFunc

hmmm, I tried this, but it is not working like I want?

Share this post


Link to post
Share on other sites

Func _sortarrayworkstations()
    $todelete = _ArraySearch($aComplist, "xxxx","","",0,1,0,0)
    For $element = 1 To $todelete Step -1
        _ArrayDelete($aCompList,$element)
    Next
EndFunc

hmmm, I tried this, but it is not working like I want?

Still making it harder than necessary. Like this:
#include <Array.au3>

Global $aComplist[12] = ["xxxx1", "yyyy2", "zzzz3", "xxxx4", "yyyy5", "zzzz6", _
        "xxxx7", "yyyy8", "zzzz9", "xxxx10", "yyyy11", "zzzz12"]

_sortarrayworkstations()
_ArrayDisplay($aCompList, "$aCompList")

Func _sortarrayworkstations()
    For $n = UBound($aCompList) - 1 To 0 Step -1
        If StringLeft($aCompList[$n], 4) = "xxxx" Then _ArrayDelete($aCompList, $n)
    Next
EndFunc

:P


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Still making it harder than necessary. Like this:

#include <Array.au3>

Global $aComplist[12] = ["xxxx1", "yyyy2", "zzzz3", "xxxx4", "yyyy5", "zzzz6", _
        "xxxx7", "yyyy8", "zzzz9", "xxxx10", "yyyy11", "zzzz12"]

_sortarrayworkstations()
_ArrayDisplay($aCompList, "$aCompList")

Func _sortarrayworkstations()
    For $n = UBound($aCompList) - 1 To 0 Step -1
        If StringLeft($aCompList[$n], 4) = "xxxx" Then _ArrayDelete($aCompList, $n)
    Next
EndFunc

:P

thanx!!

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