Menu parser

Jan Schenkel janschenkel at yahoo.com
Sun Oct 5 08:19:00 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
> 

Blegh, looks like my brain went out for a trip to the
Carribean as well (not me, unfortunately). Here's one
better suited to your purposes :

  put the text of btn "Foobar" into tMenuText
  put 0 into tLastNumTabs
  repeat for each line tMenuItem in tMenuText
    if tMenuItem is empty or \
       tMenuItem is among the items of "-,(-"
    then next repeat
    put 0 into tNumTabs
    repeat until char 1 of tMenuItem is not tab
      add 1 to tNumTabs
      delete char 1 of tMenuItem
    end repeat
    if tNumTabs > tLastNumTabs
    then delete line -1 of tStrippedList
    put tNumTabs into tLastNumTabs
    put return & tMenuItem after tStrippedList
  end repeat
  if char 1 of tStrippedList is return
  then delete char 1 of tStrippedList
  
And now tStrippedList should be what you wanted.
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