Jump to content

extracting items from an array to a new array


Recommended Posts

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
Link to comment
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
Link to comment
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?

Link to comment
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
Link to comment
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!!
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...