Desktop and both Mac and Windows
I am having a problem on R3 with Clearing my RecentItems Classes. I have “LsstRowIndex” reported as 4 but the actual COUNT is 6.
The line in the Clear method which throws an OutOfBounds is below
While me.RecentItemsQueue.LastIndex > -1
me.parent.RemoveMenuAt me.RecentItemsQueue.LastIndex// Here
Wend
I don’t know what else to include but code.
https://www.dropbox.com/sh/4n7us65t9y4dew4/AABxxDvQm7YNOp8FnHdQi2-va?dl=0
In the open for the app ( mine is in the preferences file)
MaxRecents = val(pArrayFile(rowcnt))//rowcnt = 6 App.pLimit (Protected)
Recentitems = new RecentitemsManager(FileOpenRecent)
In the open a file
RecentItems.Add(f)
As the property declaration (Mine is in the App property list)
Recentitems As RecentitemsManager
You do understand that you’re not removing things from the RecentItemsQueue when you call RemoveMenuAt right? That loop probably fails on the second call because the array and the menu no longer have the same number of items in it.
Thanks.
The previous line was
While me.RecentItemsQueue.LastIndex > -1
me.parent.Remove me.RecentItemsQueue.Pop
Wend
Which translates to (I think)
While me.RecentItemsQueue.LastIndex > -1
me.parent.RemoveAt(me.RecentItemsQueue.LastIndex) me.RecentItemsQueue.Pop
Wend
But the compiler doesn’t like it And nor do I.
Do you have a suggextion?
If you are removing all the items, try removing the first item every time through the loop (if there are six items, then remove the first item six times to get rid of all the items)
My confusion is I cannot use the line below
me.parent.RemoveMenuAt 0
as that also throws an OutOfBounds
If I remove from the queue that doesn’t mean it is removed from the parent.
Using this code
While me.RecentItemsQueue.LastIndex > 0
me.parent.RemoveMenuAt me.RecentItemsQueue.FirstIndex
Wend
I still have 4 items in the queue after iterating 4 times.
I also prefer the class I have over the exsmple.
Try it like this:
While me.RecentItemsQueue.LastIndex > -1
me.parent.RemoveAt(me.RecentItemsQueue.LastIndex)
me.RecentItemsQueue.Pop
Wend
Thanks for doing this for me. I’d left my house thinking I needed to two lines and came home to experiment. (Not really a challenging experiment, but…)
Charles Yeamons wrote a good class, but it’s hard to modernize.
Edit: slight modification
me.parent.RemoveMenuAt(me.RecentItemsQueue.LastIndex)
me.RecentItemsQueue.RemoveAt(me.RecentItemsQueue.LastIndex)