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

 
 

 

 
 
 
Posts of the actual month
Januar 2025
MoTuWeThFrSaSu
 12345
6789101112
13141516171819
20212223242526
2728293031 
 
© 2006-2025 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.