Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

X++ list of Maps

(1) ShareShare
ReportReport
Posted on by 4,016

I am going to be reading some data from a file, and I would like to make a method that reads all the lines from the file and saves them in a variable to return from the method.

The problem is that each line in the file might not have the same fields every time, but it does contain [FieldName, Value]

So I have used a Map to hold one line from the file at a time, and that works.

But now my problem is, where should I store all the Map variables per line that I get?

Anyone have an idea?

*This post is locked for comments

  • Verified answer
    jasman Profile Picture
    jasman 1,411 on at
    RE: X++ list of Maps

    Use the Array foundation class.

    static void Job186(Args _args)

    {

       Array oArray = new Array (Types::Class);

       Map   iMap = new Map(Types::Integer,Types::String);

       Map   getmap;

       MapEnumerator   gmE;

       iMap.insert(1,"Hest");

       iMap.insert(2,"Fest");

       iMap.insert(3,"Pest");

       oArray.value(1,iMap);

       iMap = new Map(Types::Integer,Types::Date);

       iMap.insert(1,18\01\1971);

       iMap.insert(2,24\12\2015);

       iMap.insert(3,01\06\2015);

       oArray.value(2,iMap);

       getMap = oArray.value(1);    

       gmE = getmap.getEnumerator();

       gmE.moveNext();

       gmE.moveNext();

       print gmE.currentValue();

       getMap = oArray.value(2);    

       gmE = getmap.getEnumerator();

       gmE.moveNext();

       gmE.moveNext();

       gmE.moveNext();

       print gmE.currentValue();

       pause;    

    }

  • Verified answer
    Rudi Hansen Profile Picture
    Rudi Hansen 4,016 on at
    RE: X++ list of Maps

    Typical, a short time sending the question here, I find the solution.

    I was trying to save the Map in a List but since I was using a List of Types::AnyType it did not work, but with a List of Types::Class it worked.

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,622 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,354 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans