Repeat for each loop assistance, please.

Scott Rossi scott at tactilemedia.com
Sun Aug 3 00:03:01 EDT 2003


Recently, yoy wrote:

> repeat for each line gameLine in fld "gamelist"
> 
> I need to obtain the line number for the current iteration. I'm error
> checking for the number of items in gameLine and if it isn't equal to 5, I
> want to raise an answer dialog and stop the script, then hilight that line
> in fld "gameList".
> 
> The other problem is that the variable might be 6 with the first 5 items
> isolated and the 6th item examined under different circumstances, ala
> checking a lotto game with or without a bonus ball number.
> 
> It has only been two days of my trial.
> 
> What can I query to get the iteration number of this loop?


Sounds like you want to use a counter to get the iteration.

put 1 into N
repeat for each line L in fld "gameList"
  put number of items of L into T
  if T <> 5 then
    answer "Incorrect number of items." titled "Error"
    set the hilitedLines of fld gameList to N
    exit to top
  end if
  # do other stuff here
  add 1 to N
end repeat


Regards,

Scott Rossi
Creative Director

Tactile Media, Multimedia & Design
Email: scott at tactilemedia.com
Web: www.tactilemedia.com




More information about the use-livecode mailing list