Menu parser

Jan Schenkel janschenkel at yahoo.com
Sat Oct 4 14:22:02 EDT 2003


--- FlexibleLearning at aol.com wrote:
> Aaaargh! Me brain's gone west and taken me
> intelligence with it....
> 
> Does anyone have a function that parses out only the
> active menuitems from a menuList? Feel free to mail
> me off-list as I am on digest. Thank you!
> 
> Example:
> Menu1
>    Menu1.1
>    Menu1.2
> (-
> Menu2
> -
> Menu3
>    Menu3.1
>        Menu3.1.1
>        Menu3.1.2
>    Menu3.2
>    Menu3.3
> Menu4
> 
> Would return...
> 
> Menu1.1
> Menu1.2
> Menu2
> Menu3.1.1
> Menu3.1.2
> Menu3.2
> Menu3.3
> Menu4
> 
> 
> /H
> 

Try this :

  put the text of btn "Foo" into tMenuText
  -- strip off the elading tabs for submenus
  replace tab with empty in tMenuText
  -- now filter out the divider lines
  repeat for each line tMenuLine in tMenuText
    if tMenuLine is not among the items of "-,(-"
    then put tMenuLine & return after tStrippedList
  end repeat
  -- finally clean up the trailing return
  delete char -1 of tStrippedList

Then the variable tStrippedList should contain what
you want. I was looking for a way to "filter" instead
of the "repeat" loop but didn't find one right away.

Hope this helped,

Jan Schenkel.

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com



More information about the Use-livecode mailing list