Snippets

SeanB Array Filtering helper method. (non-idempotent)

Created by SeanB
//Filters an array according to a passed parameter. 
//e.g. 
//move (FilterArray(aStringList,self,get_is_uppercase)) to aStringList

Function FilterArray Global Variant[] aVariant Integer hObj Integer iMsg Returns Variant[] 
    Variant[] aReturn 
    Integer iPos 
    Integer iCopied 
    Integer iMax 
    Boolean isOK 
    
    Move (SizeOfArray(aVariant)) to iMax 
    For iPos from 0 to (iMax-1) 
        Get iMsg of hObj aVariant[iPos] to isOK 
        If (isOK) Begin 
            Move aVariant[iPos] to aVariant[iCopied]
            Move (iCopied+1) to iCopied 
        End
    Loop
    Move (ResizeArray(aVariant,iCopied)) to aVariant
    Function_Return aVariant
End_Function

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.