Repeat with a list

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
RossG
Posts: 247
Joined: Thu Jan 08, 2015 7:38 am

Repeat with a list

Post by RossG » Sun May 01, 2016 3:09 am

My attempts to spit the list into a few lines have all failed.
I see that the symbol to use is "\".

How can I do this?

repeat for each item tItem in "Black10Record,High10Record,Low10Record,Odd10Record,Even10Record,Red10Record,Black20Record,High20Record,Low20Record,Odd20Record,Even20Record"
set the visible of field tItem to "false"
end repeat

Can't get the code to insert correctly.....the list should be on the "repeat" line and the " at the end of the list
has disappeared....
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Repeat with a list

Post by AxWald » Sun May 01, 2016 1:02 pm

Hi,

try false instead of "false", it's a constant and not a string!

And to have it better readable, try:

Code: Select all

   put "Black10Record,High10Record,Low10Record," & \
         "Odd10Record,Even10Record,Red10Record,Black20Record," & \
         "High20Record,Low20Record,Odd20Record,Even20Record" into MyVar
   repeat for each item tItem in MyVar
      set the visible of field tItem to false
   end repeat
Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: Repeat with a list

Post by dunbarx » Mon May 02, 2016 3:15 am

Hi.

"false" does not fool the LC parser. It will work fine either way. I always place such constants in quotes.

That said, please post verbatim the lines that are throwing the error. It is likely just a small typo or syntactical error.

Craig Newman

Opaquer
Posts: 247
Joined: Wed Aug 14, 2013 8:24 am

Re: Repeat with a list

Post by Opaquer » Wed May 04, 2016 4:06 am

RossG wrote:My attempts to spit the list into a few lines have all failed.
I see that the symbol to use is "\".

How can I do this?

repeat for each item tItem in "Black10Record,High10Record,Low10Record,Odd10Record,Even10Record,Red10Record,Black20Record,High20Record,Low20Record,Odd20Record,Even20Record"
set the visible of field tItem to "false"
end repeat

Can't get the code to insert correctly.....the list should be on the "repeat" line and the " at the end of the list
has disappeared....
Perhaps try this instead:

Code: Select all

   repeat for each item tItem in "Black10Record","High10Record,"Low10Record,"Odd10Record","Even10Record","Red10Record","Black20Record","High20Record","Low20Record","Odd20Record","Even20Record"
      set the visible of field tItem to "false"
   end repeat
That way there can't be any errors at all. Also make sure that itemDel is set to ","? Just in case it got set somewhere else? Those are my best guesses anyway - let's hope it works :P!

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: Repeat with a list

Post by Da_Elf » Wed May 04, 2016 12:17 pm

dont forget to set the item delimiter

Code: Select all

set itemDelimiter to comma
put "Black10Record,High10Record,Low10Record,Odd10Record,Even10Record,Red10Record,Black20Record,High20Record,Low20Record,Odd20Record,Even20Record" into myList
repeat for each item titem in myList
set visible of fld titem to false
end repeat

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Repeat with a list

Post by bn » Wed May 04, 2016 1:13 pm

locking the screen before the repeat loop and unlocking it after speeds this up tremendously.

Kind regards
Bernd

RossG
Posts: 247
Joined: Thu Jan 08, 2015 7:38 am

Re: Repeat with a list

Post by RossG » Sun May 15, 2016 1:16 am

The problem was lack of the "&".

I thought that the "\" would assume the following
line was to be concatenated, but it's not so.

BTW Am I the only one who always gets it wrong
between

repeat with
and
repeat for.

Seems that one or the other should be sufficient.
"repeat for" is, as far as I can remember, the usual
in other languages.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.

Post Reply