This post is machine-translated. The original post in german language can be found here.

Split a string with fixed separators

The following snippets are meant to show how to extract the individual elements from a string with fixed separators.

Variant 1: Convert the string to a container using str2con()

static void Job1(Args _args)
{
    str paramAsStr = "Wert1@@Wert2@@Wert3";
    container paramAsCon;
    int i;

    paramAsCon = str2con(paramAsStr, "@@");
    
    for (i=1;i<=conLen(paramAsCon);i++)
    {
        info(conPeek(paramAsCon, i));    
    }
}


Variant 2: Convert the string to a list using strSplit()

static void Job1(Args _args)
{
    str paramAsStr = "Value 1|Value 2|Value 3";
    List paramAsList;
    ListEnumerator le;

    paramAsList = strSplit(paramAsStr, "|");
    
    le = paramAsList.getEnumerator();
    while(le.moveNext())
    {
        info(le.current());    
    }
}

 

These post applies to following version:
Dynamics AX 2012

Add comment
 
 

 

 
 
 
Posts of the actual month
März 2024
MoTuWeThFrSaSu
 123
45678910
11121314151617
18192021222324
25262728293031
 
© 2006-2024 Heinz Schweda | Imprint | Contact | German version | Mobile version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.