[futurebasic] Re: [FB] [FB^3] PopUp Menu Question

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 1999 : Group Archive : Group : All Groups

From: jonathan <jonnnathan@...>
Date: Mon, 08 Nov 1999 00:54:35 +0100
le 7/11/99 23:48, Ken Shmidheiser à kshmidheiser@... a écrit :

> I have encountered a question concerning calling procedures from a
> popup menu. Sample self-running code will follow in the next post,
> but the binhexed ResEdit resource file needed to run the demo is
> included at the end of this message. (It's real small, I hope Bill
> and you list members don't mind.)
> 
> Here's the problem:
> 
> In the demo code you will see that I call the record arrays using the
> popIndex$ string which references each individual name string in the
> popup menu. While the system works fine, it is less than elegant--
> particularly for the more complex project I have been developing. I
> would prefer to use a number for each item in the popup menu.
> 
> What I would like to know is, short of adding a number into each name
> string in the menu, and then trimming out the number and converting
> the string to a value, i.e.:
> 
> "Bowerbird" in the popup menu becomes "1. Bowerbird" with the 1 later
> filtered out for referencing,
> 
> is there any way to reference an item in a popup menu other than by
> its name string-- preferably by a number?

Ken

I think that i must be particularly gnomish on this...
you have a list of entries in a pop-up menu (or a vanilla type)
you want, from the selected entry, to get a numerical result?

what about menu item?
this is so simple... that I think I must have missed something...
I'll suppose that you're creating the menu on the fly and that the entries
rather than being in a fixed spot will depend on the context...

OK. bin there done that (not in FB^3, but the principles must be pretty
similar)

In my case I used a STR# resource:
- entering the routine to build the menu I grabbed an empty STR# that I had
prepared for that case
- then I scaned the info passed to the FN to find what I should include in
the STR# and pushed in the resource in the order they came
- next I sorted the STR# alphabetically, this was with a routine by Mars
that I found in his LIST utilities
- then I parsed the STR# building the menu
- when i got a choice I used the menu item number to get the string from the
STR# - here you'd probably use just the offset (nth chosen)
- then I killed everything
This was damn qquick as everything had to happen *when* the user clicks on
the pop-up menu and there was no noticeable delay in there.

Now, suppose that the action that you take depending on the pop-up menu
choice is dependant on the choice... again, the contents of the menu varying
over time... I can see 2 ways of doing this (others'll find more):

build 2 STR#s - and adapt Mars' routines to more the second resource at the
same time it alphabetises the first

or

have a big SELECT/CASE routine with all you possibilities in and have this
build the menu and a 'hidden' record at the same time, then the menu item
result will give you, again, the result for the action.

quite frankly, i don't see how any of this can be done without a second
record, but as this doesn't look difficult enough, i expect you to now tell
me that I have misunderstood the problem.

:-j
(a flattered and flattened gnome)