cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pwintert
Frequent Visitor

Indexing into a List using a variable

I have a rather lengthy list I have created in P.A.D. That is a few hundred lines long of text.   There is some information on every 4th line I want to pull out and create a new list for.    I created a simple loop in which I increment an index counter called "Position" by 4 and create a new item for my new list.

 

My Code inside Add item to list is as follows:

 

%MyList[Position]% 

 

My problem is that it is adding every fourth character of the first element in MyList.  When I need it to grab every 4th element of the list.  Its accessing the characters of MyList as if it were a String instead of the elements inside the List.  I'm sure its just a syntax error on my part but I read through a few forums but couldnt find my answer. Hopefully someone on here can lend me a hand.    

1 ACCEPTED SOLUTION

Accepted Solutions
pwintert
Frequent Visitor

I went in and changed some of my code.  It is working now.  The short version is that I inadvertently converted my List to a string while trying to replace some characters in my List. It was my first time using a variable in POD to reference my List so I assumed that my mistake was there. Turns out that when I replaced characters in my list it was converting the list back into a string and not back in a List like I thought.  Discovered my mistake by verifying my length of my List.  

View solution in original post

3 REPLIES 3
ryule
Responsive Resident
Responsive Resident

That sure seems like it would work based on what I know about lists.....could you share a screenshot of what your config looks like?

pwintert
Frequent Visitor

I went in and changed some of my code.  It is working now.  The short version is that I inadvertently converted my List to a string while trying to replace some characters in my List. It was my first time using a variable in POD to reference my List so I assumed that my mistake was there. Turns out that when I replaced characters in my list it was converting the list back into a string and not back in a List like I thought.  Discovered my mistake by verifying my length of my List.  

VJR
Super User
Super User

Great you found the issue and got it working. You can close the thread now.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Top Solution Authors
Top Kudoed Authors
Users online (3,063)