03-12-2023, 05:29 PM
Here is it - MapSet and MapGet - 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