Discuss issues and ideas you have to configuring displays with PowerVision
-
JoakimMD
- Posts: 20
- Joined: Fri Oct 22, 2010 9:17 am
Post
by JoakimMD » Thu Jun 30, 2016 7:17 am
Hi all,
Have a problem with "ListManagerRemoveItem". When I run this event it will not remove all rows. Row 0-2 still remains in the list. If i run the event again it will remove row 1-2. And if I run it one more time row 0 will be removed.
Why?
Code: Select all
int rows = ListManagerGetCount(ListDataType.DataList);
for (int index = 0; index < rows; index++)
{
ListManagerRemoveItem(ListDataType.DataList, index);
}
Thanks!
-
stalley
- Enovation Controls Development
- Posts: 618
- Joined: Tue Mar 18, 2014 12:57 pm
Post
by stalley » Thu Jun 30, 2016 7:36 am
Hello JoakimMD,
What version of PowerVision Configuration Studio are you using?
The processes on the displays are asynchronous. Is it possible rows are being added just after the remove function is run?
This could very well be a bug. If you give me more details, I can try to recreate the problem. If I build up a static list of five items, then run your function, should I see the problem?
Thanks!
Sara Talley
Software Engineer
Enovation Controls
-
stalley
- Enovation Controls Development
- Posts: 618
- Joined: Tue Mar 18, 2014 12:57 pm
Post
by stalley » Thu Jun 30, 2016 9:04 am
Hello JoakimMD,
Well I am so embarrassed! What is the fundamental programming rule of deleting from an array? Start at the end or highest index ... cause if you start at 0, the elements will move up and the indexes change.
The loop needs to be
for (int index = rows; index >= 0; index--)
Hope this will work for you!
Sara Talley
Software Engineer
Enovation Controls
-
JoakimMD
- Posts: 20
- Joined: Fri Oct 22, 2010 9:17 am
Post
by JoakimMD » Thu Jun 30, 2016 9:49 am
Ha ha... I´m embarrassed too... :)
I figured that out and has now changed the code but in a slightly different way.
Code: Select all
for (int rows = ListManagerGetCount(ListDataType.DataList); rows >= 0; rows--)
{
ListManagerRemoveItem(ListDataType.DataList, rows);
}
Thanks!