Option menu

Klaus Major klaus at major-k.de
Sat Feb 17 11:11:25 EST 2007


Hi Michael,

> Hello
> I have a fld with with a list of 100 or so lines with itemdel for  
> the first item of each line. How can I get each lines item1 into  
> the option menu ?
> so far this gets the first line of the fld into the option menu but  
> not addtional lines.
>
> put item 1 of fld "sortfld" into btn "menuS"
>
> so I think its,
> put fld "sortfld" into var
> repeat with i=1 to the number of lines in var
> put ? not sure here
> end repeat
> put var into btn "menuS"

You already set the itemelimiter, did I understand this correctly?

The fastest way will be:

...
set the itemdelimiter to XXX
## replace XXX with your itemdelimiter like TAB, "," or whatever!!!

put fld "sortfld" into var

## "repeat for each ..." is insanely fast, but READ ONLY!
## That means you cannot alter the variable (i in this case), only  
read the value(s)!
repeat for each line i in var

   ## In this loop we collect all the first items into a CR delimited  
list
   put item 1 of i & CR after newlist
end repeat

## Get rid of trailing CR
delete last char of newlist

put newlist into btn "menuS"
## Done :-)
...


> Thanks for any  help
> Michael

Best

Klaus Major
klaus at major-k.de
http://www.major-k.de




More information about the use-livecode mailing list