Snippets

SeanB Dataflex - Split String to an array

Created by SeanB
Function SplitToArray Global String sVal String sChar Returns String[]
    String[] astVal
    String sHold
    Integer iCount
    Integer iPos 
    Integer iBreak
    Integer iMax 
    
    Move (Length(sVal)) to iMax 
    Move (Length(sChar)) to iBreak 

    Move 0 to iCount 
    Repeat 
        Move (Pos(sChar,sVal)) to iPos
        If (iPos<>0) Begin 
            Move (Left(sVal,iPos-1)) to astVal[iCount]
            Move (Mid(sVal,iMax,(iPos+iBreak))) to sVal 
        End
        Else Begin 
            Move sVal to astVal[iCount]
        End
        Increment iCount
    Until (iPos=0)
        
    Function_Return astVal
End_Function // Split

Comments (0)

HTTPS SSH

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