web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Splitting a string with multiple lines

(0) ShareShare
ReportReport
Posted on by 275

Hi

I am having a problem, i am trying to splitting a string. But i having problems with it.

I have read about using StrLine, but it complicates it a bit.

Str  text = 2013: 1512 2014: 25222 2015: 35233 2016: 1623233;

// Prints "second-line".
    print strLine(text,1);
 
// Prints "last-line".
    print strLine(text,2); 
    pause;

Does'nt work. It needs "\n"

So i thought of making a loop that inserts "\n" ?
And StrIns only works if you know the which position to insert in. Which i don't,
when the amounts can change.

Please help

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Rudi Hansen Profile Picture
    4,075 on at

    You could use str2Con to convert your string into a container.

        Str         text = '2013: 1512 2014: 25222 2015: 35233 2016: 1623233';
        container   data;
        
        data = str2con(text,' ');
        print conPeek(data,1) + ' ' + int2str(conPeek(data,2));
        pause;
    


    Extra benefit is that you actually get your data in a structure that is also a little easier to work with.

  • Ashein Profile Picture
    275 on at

    It actually worked. Not the way i imagined. But thank you very much.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans