String pairs to menus and sub-menus

I receive lists generated by SQL queries that need to be made available as menuitems.

“A” could be COLORS where 1 is red, 2 is blue.

“B” could be CAR MODEL where 1 is Chevrolet, 2 is Ford, etc.

A 1
A 2
B 1
B 2
B 3
B 4
B 5
C 1
C 2
C 3

I would like to condense them down to this:

A 1, 2
B 1, 2, 3, 4, 5
C 1, 2, 3

A-C represent menu items in a contextual menu. The numbers next to them in the list above would pop out from each letter item in the pop-up as sub-items.

Constructing the actual menus shouldn’t be a problem, but I have been spinning my wheels trying to figure out how to get this pared down in a usable format.

My first instinct was to use a dictionary, but I cannot figure it out.

Any suggestions?

Thanks.

If you had a dictionary, let’s say it’s called “d”, you could do something like this:

While not myRowSet.AfterLastRow
    Dim Arr() as String 
    Arr = d.Lookup(category, arr)
    Arr.Add type
    d.Value(category) = arr
    myRowSet.MoveToNextRow
Wend

(Typed without my computer, so it may not compile)

I was unable to use that exact code. I’m sure the biggest reason is that I’m using REAL Studio 2011r1.

However, I was able to use the same principals to get this to work, but instead of using an array, I built a pipe delimited string.

Thanks!

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.