LARGE TKN/EXE MENU

Gordon Sweet
gordon@gsweet.fsnet.co.uk

Regular readers to these Newsletters will no doubt have seen my quaint way of creating multi button menus before. I am not against using the standard Windows type buttons, but unless someone can prove me wrong, I think it would be a far more complex and laborious task to created a button menu of more that say about a dozen options, especially to replace this version which can handle up to 203 TKN or EXE files. This one could also be used as a CD menu. I doubt if any of us have managed to create that many LB TKN files all of our own, but given permission from the authors some might find manage to create a sufficiently large enough collection to merit the its use. It can of course cope with EXE files, providing you know they work under Windows, which includes DOS programs produced using say QuickBasic. The menu could easily be used as a CD menu, remembering to create and burn in the root an AUTORUN.INF using Notepad such as
[autorun]
open=CDmenu.exe

The program is fairly straight forward and is designed to make use of the current popular larger 15 inch or higher Monitors, which usually have a screen display of at least 1024 x 768 setup. So the first step is the use of a warning Notice if a smaller display setting is detected. The first section [menu] is based on the very useful DIR.BAS supplied with LB, note the type$ filter is first set toTNK just before [menu] so that once a list has been created in prog$ and it detects ext$ as being TKN, it changes ext$ to “EXE” and returns to [menu]. Study the use of the Sub function noPath$(t$) that I believe was devised by Alyce some time ago.

Notice I have used a standard Sorting routine instead of the SORT of LB, to allow this program to also run under Just Basic.

The [show] section displays the buttons, which you can easily change the colours to suit yourself. Finally the [which] button detecting routine culminating in   run cf$     Remove or change the “ping” wav which defaults to a Windows setting to suit yourself. Note the first button defaults to the [list] option to create a filelist.txt of all the TKN bas EXE files found in the working directory.

    nomainwin
    if DisplayWidth < 1024 then
        notice "Program unsuitable for displays smaller than 1024 x 768"
        end
    end if
[start]
    open "SELECT A FILE BELOW - NOTE first option" for graphics_fs_nsb as #m
    #m "trapclose [quit]; down; when leftButtonDown [which]"
    #m "font arial 7; fill 1 1 100"
    #m "backcolor 100 40 10; color white"
    dim prog$(300) : dim dir$(10,3) : dim info$(1,1)

    c=1 : ext$="TKN"
[menu]
    File$ = upper$(File$)
    sFile$ = noPath$(File$)
    plen = len(File$)-len(sFile$)
    path$ = left$(File$,plen)
    type$ = "*." + ext$
    files path$, type$, dir$()
    qtyFiles = val(dir$(0, 0))
    if qtyFiles > 203 then notice "LIMIT = 203 files ": goto [quit]
    for x = 1 to qtyFiles
        dir$(x, 1) = right$("        " + dir$(x, 1), 9)
    next x : miss = 0
    for x = qtyFiles to 1 step -1
        ts$ = left$(dir$(x, 0) + "            ", 50)
        ts$ = upper$(trim$(ts$))
        prog$(c) = ts$ : c = c + 1
    next x
    if ext$ = "TKN" then ext$ = "EXE" : goto [menu]
    prog$(c) = "* SAVE filelist.txt *"

    FOR R = 1 TO c - 1
        FOR K = R + 1 TO c
            IF prog$(K) < prog$(R) THEN
                T$ = prog$(K)
                prog$(K) = prog$(R)
                prog$(R) = T$
            END IF
        NEXT K
    NEXT R
    max = c

[show]
    y = 15 : C = 1
    for row = 1 to 29
        x = 40
        for colm = 1 to 7
            #m "place ";x;" ";y
            #m "boxfilled ";x+100;" ";y+15
            #m "place ";x+6;" ";y+11
            #m "\";prog$(C)
            C = C + 1
            x=x+140
        next colm
        x = 1
        y = y + 24
    next row
    ymax = y - 10
    #m "flush"
[hold]
    playwave "ping" : wait

[which]
    x=MouseX : y=MouseY

    if x < 40 or x > 980 then [hold]
    if y < 15 or y > 700 then [hold]
    upper = 15 : lower = 30 : row = -1
    for dat = 1 to 29
        if y > upper and y < lower then row = dat -1
        upper = upper + 24 : lower = lower + 24
    next dat
    row = row * 7
    upper = 40 : lower = 140 : item = 0
    for dat = 1 to 7
        if x > upper and x < lower then item = dat
        upper = upper + 140 : lower = lower + 140
    next dat
    if dat = 0  or row < 0 or item =0 then [hold]
    item = item + row : if item > max then [hold]
    opt$ = prog$(item): cf$ = lower$(prog$(item))
    if item = 1 then [list]
    close #m

    run cf$,restore
    playwave "ping"
    confirm "Select Another Program ?"; q$
    if q$="yes" then [start] else end

[more]
    confirm "Select another ?"; q$
    if q$ = "yes" then [start] else end

[list]
    OPEN "filelist.txt" FOR OUTPUT AS #2
    FOR n = 1 TO c
        #2 n;" : ";prog$(n)
    NEXT n : close #2
    notice "filelist.txt SAVED."

[quit]
    close #m : end

    function noPath$(t$)
    while instr(t$, "\")
    t$ = mid$(t$, 2)
    wend
    noPath$ = t$
    end function