BAM: [new] _MAPSET and _MAPGET
#6
Here is it - MapSet and MapGet Smile - but first DIM definitons are need.


Code: (Select All)
Type MapSet_Internal
    v As String
    value As Integer
End Type
ReDim Shared MU(0) As MapSet_Internal


MapSet "CARROT", 1
MapSet "CORN", 2
MapSet "POTATO", 3

MAIN_PROGRAM:

getselection:
Input "Search for recipes: enter one ingredient:", selection$
selection$ = UCase$(selection$)
If MapGet(selection$) = 0 Then Beep: Print "sorry, no recipes for " + selection$: GoTo getselection

On MapGet(selection$) GOSUB CARROT, CORN, POTATO

GoTo getselection

End

SUBROUTINES:

CARROT:
Print "setup special processing for carrot-related recipes and info CARROT"
Return

CORN:
Print "setup special processing for corn-related recipes and info CORN"
Return

POTATO:
Print "setup special processing for potato-relatd recipes and info POTATO"
Return


Sub MapSet (something As String, value)
    u = UBound(MU)
    MU(u).v = something$
    MU(u).value = value
    ReDim _Preserve MU(u + 1) As MapSet_Internal
End Sub

Function MapGet (value$)
    U = LBound(MU)
    Do Until m = UBound(MU)
        V$ = _Trim$(MU(m).v)
        If V$ = value$ Then MapGet = MU(m).value: Exit Function
        m = m + 1
    Loop
    MapGet = 0
End Function


Reply


Messages In This Thread
BAM: [new] _MAPSET and _MAPGET - by CharlieJV - 03-11-2023, 06:46 PM
RE: BAM: [new] _MAPSET and _MAPGET - by CharlieJV - 03-11-2023, 11:18 PM
RE: BAM: [new] _MAPSET and _MAPGET - by Petr - 03-12-2023, 10:41 AM
RE: BAM: [new] _MAPSET and _MAPGET - by CharlieJV - 03-12-2023, 04:16 PM
RE: BAM: [new] _MAPSET and _MAPGET - by CharlieJV - 03-12-2023, 04:28 PM
RE: BAM: [new] _MAPSET and _MAPGET - by Petr - 03-12-2023, 05:29 PM
RE: BAM: [new] _MAPSET and _MAPGET - by CharlieJV - 03-12-2023, 06:28 PM
RE: BAM: [new] _MAPSET and _MAPGET - by Petr - 03-12-2023, 06:55 PM
RE: BAM: [new] _MAPSET and _MAPGET - by CharlieJV - 03-12-2023, 08:19 PM



Users browsing this thread: 4 Guest(s)