OK, here it is.
This is for the Games menu in a video poker program. The Games menu is created in the editor as follows:
Text Index Name
Jacks or Better 0 GamesJB
All American 1 GamesAA
Bonus Poker 2 GamesBP
Double Bonus 3 GamesDB
etc.
Each has Submenu checked.
=================== Here’s my current code in the method BuildGamesMenu
’ Scan all the files in the Games folder, and build the Games menu
dim x, y, z, n as integer
dim Fname, Gname, Bname as string
dim f as FolderItem
dim m as MenuItem
dim Found as boolean
f = GetFolderItem( “Games” ) ’ Find the Games folder
if not f.directory then FolderError “Games”
n = f.count ’ Confirm that the Games folder is not empty
if n < 1 then FolderError “Games”
z = 0
for x = 1 to n ’ Accumulate game filenames, ignoring hidden Mac files
Fname = f.item( x ).name
if left( Fname, 1 ) = “.” or right( Fname, 4 ) = “.DAT” then continue
Gname = replaceAll( Fname, “-”, “/” )
redim GameNames( z )
GameNames( z ) = Gname
z = z + 1
next
GameNames.sort ’ Alphabetize the game names
DefaultGame = 0 ’ If JoB 9/6 doesn’t exist, the first JoB game will be the default
BuildGnamesArray ’ The Gnames array defines the Games sub-menus structure
’ ******* Everything up to here has been verified to be working properly ********
for x = 0 to z-1 ’ Loop to put the game names in the proper sub-menus
Gname = GameNames( x ) ’ Get a game name
Found = false ’ Flag to be set when a match has been found
for y = 0 to 7 ’ Scan the Gnames array to determine the game category
for z = 0 to 10 ’ Scan this game category for this game name
Bname = Gnames( y, z ) ’ One of the basic game names
if Bname = “” then exit ’ Check if done with this category
if Bname = left( Gname, len( Bname ) ) then ’ Is it a match?
select case Gnames( y, 0 ) ’ yes, append an item in this category
case “JB”
m = new GamesJB
case “AA”
m = new GamesAA
case “BP”
m = new GamesBP
case “DB”
m = new GamesDB
case “DD”
m = new GamesDD
case “TD”
m = new GamesTD
case “DW”
m = new GamesDW
case “JW”
m = new GamesJW
case else
m = new GamesOther
end
m.text = Gname
Found = true
if Gname = “Jacks or Better 9/6” then ’ Save position of default game
DefaultGame = x ’ It’s at this position in the GameNames array
end
exit
end
next z
if Found then exit
next y
next x
EnableMenuItems ’ May be redundant *****
CurrentGame = DefaultGame ’ Select the default game
GameName = GameNames( CurrentGame )
LoadGame( GameName )
exception err
if err isa EndException then
raise err ’ This will be handled in App.UnhandledException
end
=================== Here’s my current code in the method BuildGamesArray
’ 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.
Gnames( 0,0 ) = “JB”
Gnames( 0,1 ) = “JoB”
Gnames( 0,2 ) = “Jacks or Better”
Gnames( 0,3 ) = “AF”
Gnames( 0,4 ) = “Aces”
Gnames( 0,5 ) = “”
Gnames( 1,0 ) = “AA”
Gnames( 1,1 ) = “All American”
Gnames( 1,2 ) = “Gator”
Gnames( 1,3 ) = “”
Gnames( 2,0 ) = “BP”
Gnames( 2,1 ) = “Bonus Poker”
Gnames( 2,2 ) = “”
Gnames( 3,0 ) = “DB”
Gnames( 3,1 ) = “Double Bonus”
Gnames( 3,2 ) = “DJ”
Gnames( 3,3 ) = “Double Jackpot”
Gnames( 3,4 ) = “DF”
Gnames( 3,5 ) = “Double Faces”
Gnames( 3,6 ) = “”
Gnames( 4,0 ) = “DD”
Gnames( 4,1 ) = “Double Double”
Gnames( 4,2 ) = “Dbl Dbl”
Gnames( 4,3 ) = “DblDbl”
Gnames( 4,4 ) = “”
Gnames( 5,0 ) = “TD”
Gnames( 5,1 ) = “Triple Double”
Gnames( 5,2 ) = “”
Gnames( 6,0 ) = “DW”
Gnames( 6,1 ) = “Deuces Wild”
Gnames( 6,2 ) = “FPDW”
Gnames( 6,3 ) = “NSUD”
Gnames( 6,4 ) = “Not So Ugly”
Gnames( 6,5 ) = “BD”
Gnames( 6,6 ) = “Bonus Deuces”
Gnames( 6,7 ) = “DWB”
Gnames( 6,8 ) = “LD”
Gnames( 6,9 ) = “Loose Deuces”
Gnames( 6,10 ) = “”
Gnames( 7,0 ) = “JW”
Gnames( 7,1 ) = “Joker Wild”
Gnames( 7,2 ) = “DJ”
Gnames( 7,3 ) = “Double Joker”
Gnames( 7,4 ) = “”
’ Any game name that doesn’t start with one of the above strings
’ will be put in the “Others” sub-menu