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)

X++ list of Maps

(1) ShareShare
ReportReport
Posted on by 4,075

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

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

    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.

  • Verified answer
    jasman Profile Picture
    1,413 on at

    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;    

    }

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
Priya_K Profile Picture

Priya_K 4

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 3

#3
Scott_itD Profile Picture

Scott_itD 2 Community Manager

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans