process of creating menuitem array?

Is there a tutorial, article, or blog post on this subject? I just learned the term “menuitem array” and tried looking up info on it and I cannot find anything.
I don’t know if this is also called dynamic menu.
I also don’t understand how to use menuitem.remove for creating an array since there is an index.
I am interested in a recent items menu list that can be saved. There is a Blog post on a window menu but that is a bit different.

What is it you want to achieve ?

I am interested in a recent items menu list that can be saved.


Thanks but it doesn’t completely answer the array piece. It for instance doesn’t mention index

Index is the index :slight_smile: You would only need it if you wanted to (among other things) Insert into a specific point in the menu list or Remove an entry at a specific point in the menu list. To create a menu use Append which will add the entry to the end of the menu list.

When you are in the IDE, hit F1 or open the Language Reference (help) and type MenuItem into the search, the read the entire page. There’s examples about half the way down that page (under Examples) that explain how to use indexes.

Let us know if you have any more questions :slight_smile:

This is what I’ve done with remembering previously used file entries:

My part in the App.EnableMenuitems method:

if Remember(0)<>0 then //When first file to remember is not empty if Deleted(Remember(0))=False then //User still not has deleted this file in the main list if GameTitle(remember(0))<>"" then RecentMenuitem(0).Enable RecentMenuitem(0).Visible=true RecentMenuitem(0).Text=GameTitle(Remember(0)) else //GameTitle(remember(0))="" //then RecentMenuitem(0).Enabled=False RecentMenuitem(0).Visible=False RecentMenuitem(0).Text=GameTitle(Remember(0)) end if end if for i = 1 to 5 if Remember(i)<>0 then if Deleted(Remember(i))=False then if GameTitle(remember(i))<>"" then RecentMenuitem(i).Enable RecentMenuitem(i).Visible=true RecentMenuitem(i).Text=GameTitle(Remember(i)) //Text of the menu item else //GameTitle(remember(i))="" //then RecentMenuitem(i).Enabled=False RecentMenuitem(i).Visible=False RecentMenuitem(i).Text=GameTitle(Remember(0)) end if end if else //Deleted(Remember(i))=true RecentMenuitem(i).Enabled=False RecentMenuitem(i).Visible=False RecentMenuitem(i).Text=GameTitle(Remember(i)) end if next i else //Remember(0)=0, see the very first if statement located above RecentMenuitem(0).Enabled=False for i = 1 to 5 RecentMenuitem(i).Enabled=False RecentMenuitem(i).Visible=False RecentMenuitem(i).Text=GameTitle(Remember(0)) next i end if

Menu Handler:

CurrentSelGame=remember(index) //Plus, do something to open this file

When a new file will be touched, run the method listed below, the app.RememberLastGame method:

[code]dim a,i as Integer
dim doremember as Boolean
//CurrentSelGame in this example is the file to be remembered (“current file”)

for i = 0 to 5
if Remember(i)=CurrentSelGame then //when the current used file is already in the list, don’t remember it again
end if
next i

if doremember=true then //when a new entry will be added to the list
if Remember(5)<>0 then
for i = 1 to 5 //move the remember(i) entries upwards (put 0 away, 1 to 0, 2 to 1, 3 to 2 and so on),…
next i
Remember(5)=0 //…make the last one empty for new file
end if
if Remember(0)<>0 then
for i = 5 to 0 step -1 //downwards
if Remember(i)=0 then //find the Remember(i) var to store the current file
end if
next i
end if
end if //doremember

'#if DebugBuild then
'MsgBox “Debugbuild: “+str(Remember(1))+”, “+str(Remember(2))+”, “+str(Remember(3))+”, “+str(Remember(4))+”, “+str(Remember(5))+”.”

And yes, the Remember(i) properties are saved in the preferences file. :wink:

Thank you. It look very complete.

I found the reason why all of a sudden I was seeing a number in Index in the MenuItem. The process is documented in this post.
I was using 2017 R3. Apparently it’s been resolved.

Changing a menuitems name in the IDE always adds an index breaking your code

Oops, I noticed this automatically adding of an index as well. But there is no problem removing it.

You’re right, my solution written above looks very complete, with app.enablemenus, app.menuhandler and a method handling all the remembered entries. I hope it was not an overloaded type of posting. :wink: