SC to RR menu problem

Robert Presender rpresender at
Mon Oct 14 09:21:00 EDT 2002

On Sunday, October 13, 2002, at 10:57  PM, Jeanne A. E. DeVoto wrote:

> At 6:28 AM -0700 10/13/2002, Robert Presender wrote:
>> 1.     After copying a card, in SC, it is possible to include the name
>> of the new card as a menu item(s) into a particular menu and also
>> directly include a script for this new menu item(s).
>> In RR, I am able to create the new menu item(s) into the applicable 
>> btn
>> menu(of a group of menus) on the new card. I have tried many 
>> approaches
>> to create a script for the new menu item(s) without success.
>> I assume that it is not possible to directly set a script for the new
>> menu item.  I also assume that the menuPick pWhich routine of the btn
>> menu has to be modified to include the case,etc routine for the new
>> menu item.
>> My problem is that I haven't been able to create a script ( in the On
>> New routine  in the Main Stack script) to modify the menuPick routine
>> or whatever for the new menu item.
> Modifying a script is basically like modifying any other property: you 
> put
> the property into a variable, make the changes you need, then set the
> property back to the variable:
>   on newCard
>     put the script of button "Cards" into myScript
>     -- make changes to myScript
>     set the script of button "Cards" to myScript
>   end newCard
> However, it's a bit awkward to do this if the script is at all 
> complicated,
> because you have to do a bit of parsing to find the desired handler, 
> then
> add new lines without disrupting the control structures in the 
> handler. In
> this case, I would suggest instead writing a general-purpose handler 
> that
> can be used regardless of the menu contents:
>   on menuPick theItem -- goes in button menu script
>     if there is a card theItem then go card theItem
>     else beep -- card wasn't there
>   end menuPick
> This works for all card names, and doesn't require a modification every
> time you add a card - it just works off the card name in the menu, so 
> all
> you need to do is add the card name to the button's text to have the 
> menu
> routine work.
> If the menu has menu items other than card names, you can write 
> specific
> case structures for those items, for example:
>   on menuPick theItem
>     switch theItem
>     case "Previous"
>       go previous card
>       break
>     case "Next"
>       go next card
>       break
>     default -- if none of the previous cases apply:
>       if there is a card theItem then go card theItem
>       else beep
>     end switch
>   end menuPick

I added a default routine to the applicable btn menu.  It did the 
trick.  Thanks

>> 2.  In SC, when a new menu item is created in the copied card's menu,
>> the new menu item also appears in the original card's menu.  This
>> appears not to happen in RR.  Is a work around necessary to include 
>> the
>> new item in the original card's menu?
> If you mean the same menu bar displayed on more than one card, this 
> should
> work - the menubar group is the same object, so changes made on one 
> card
> should be reflected everywhere the group is placed. Can you say more 
> about
> how you did this, what steps you followed?

I noted, in the Application OverView, that a cloned card has a copy of 
menu group of the basic card but the basic card's applicable menu 
didn't include the new menu item of the cloned card.

Also noted that a previously cloned card's applicable menu didn't 
include the menu item of a subsequently cloned card.

The following script was added to the new card handle in the main stack 
script to accomplish the above observations:
--adds a menu item with the name of the cloned cd to all cloned cards'  
btn menu.
   --this allows the user to go to another cloned card in the same stack 
when in one of the cds.
   get the number of cds of stack stkName
   repeat with x = it down to 2 -- cd 1 is the basic card
   put cr & holdName after last line of btn menux of cd x--creates & 
names the new menu item
   end repeat

   --When more than 1 cd is cloned, the basic card needs all the new 
items so that
   --any new cloned cds will now have all previous menu items in its btn 
   put cr & holdName after last line of btn menux of cd ID cdID of stack 
stkName --basic card

Any comments that you may have will be welcomed.

I now will have to script to delete the applicable menu item from all 
applicable cds when a cd is deleted.  No problem is anticipated at this 

Thank you for your help Jeanne.

Regards ... Bob

More information about the use-livecode mailing list