OK suppose BuildGNamesList is like
[code]Function BuildGnamesList() As dictionary
’ This is used to built the Games menu
’ For example, any game name starting with JB, JoB, Jacks or Better, etc.
’ will be category JB, and will be put in the GamesJB sub-menu.
’ the key is the category and the attached array is the list of game prefixes allowed for this category
dim gnames as new dictionary
Gnames.value( “JB” ) = array( “JB”, “JoB”, “Jacks or Better”, “AF”, “Aces” )
Gnames.value( “AA” ) = array( “AA”, “All American”, “Gator” )
Gnames.value(“BP”) = array ( “BP”, “Bonus Poker” )
Gnames.value( “DB” ) = array( “DB”, “Double Bonus”, “DJ”, “Double Jackpot”, “DF”, “Double Faces” )
Gnames.value( “DD” ) = array( “DD”, “Double Double”, “Dbl Dbl”, “DblDbl” )
Gnames.value( “TD” ) = array ( “TD” , “Triple Double” )
Gnames.value(“DW”) = array ( “DW”, “Deuces Wild” , “FPDW”,“NSUD”, “Not So Ugly”, “BD”, “Bonus Deuces”, “DWB”, “LD”, “Loose Deuces” )
Gnames.value( “JW” ) = array( “JW”, “Joker Wild”, “DJ”, “Double Joker” )
return gnames
End Function
[/code]
Now the code I whipped together to build the menu looks like
[code]
// use whatever code you want to grab the list of names from a file system etc
dim gamenames() as string
gamenames.append “jb”
gamenames.append “dueces”
gamenames.append “asmdijasd”
gamenames.sort
// get the dictionary that defines how the menu bar should be laid out and what prefixes match what categories
dim gnames as dictionary = BuildGnamesList( ) ’ The Gnames array defines the Games sub-menus structure
// now what were going to do is make several passes though our list of categories & acceptable prefixes
// and every time we find one that is acceptable we add it to the categories menu item
for each key as string in gNames.Keys
// get the list of acceptable prefixes
dim arr() as string = gNames.Value( key )
// add a menu bar item for this category
dim mbarEntry as new Menuitem( key )
MainMenuBar.Append mBarEntry
// now check all the ahems & see if they match the acceptable list of prefixes
for i as integer = ubound(gamenames) downto 0
for j as integer = ubound(arr) downto 0
if left( gamenames(i), len(arr(j))) = arr(j) then
// this one does so we can add it to this menu items sliest and
// remove it from consideration for other menu entries
dim subitem as new MenuItem( gamenames(i) )
mbarEntry.Insert 0,subItem
gamenames.Remove i
exit // since we know it wont need to match others
end if
next
next
next
// by the time we get here the only ones left are unmatched
dim mbarEntry as new Menuitem( “Other” )
MainMenuBar.Append mBarEntry
for i as integer = ubound(gamenames) downto 0
dim subitem as new MenuItem( gamenames(i) )
mbarEntry.insert 0, subItem
next[/code]
And note that simply by altering how the dictionary is created you can move things around from one category or add new ones