repeat repeat

Dick Kriesel dick.kriesel at mail.com
Wed Mar 1 20:43:50 EST 2006


If speed matters, you could avoid nesting the loops.

on mouseUp
  repeat with i = 1 to number of buttons
    put i into tArray[the label of button i]
  end repeat
  repeat for each item tSeatNo in field "seatNo"
    set the backgroundColor of button tArray[tSeatNo] to "red"
  end repeat
end mouseUp

-- Dick



On 3/1/06 4:54 PM, "Mark Schonewille" <europe at ehug.info> wrote:

> Hi Liam,
> 
> Assuming that your original code does not cause any errors, the
> following should work, although I didn't test it:
> 
> on mouseUp
>    repeat for each item myLabel in fld "seatNo"
>      repeat with x = 1 to the number of buttons
>        if myLabel is the label of btn x then
>          set the backgroundColor of btn x to red
>        end if
>      end repeat
>    end repeat
> end mouseUp
> 
> Instead of "item myLabel" you could also use "line myLabel".
> 
> Best,
> 
> Mark
> 
> 
> liamlambert wrote:
>> My fld "seatNo" has more than one line or item
>> I want to repeat the code below for each line or item
>> 
>> 
>> on mouseUp
>>   put fld "seatNo" into tseatNo
>>  repeat with x = 1 to the number of buttons
>>  if tseatNo = the label of button x then
>>       set the backgroundcolor of  button x to red
>>   end if
>>   end repeat
>>     end mouseUp
>> 
>> Liam Lambert
>> liamlambert at mac.com
>> IRELAND





More information about the Use-livecode mailing list