repeat loop - exit to top

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
jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

repeat loop - exit to top

Post by jalz » Sun Feb 22, 2015 7:30 pm

Hey all,

I have a repeat loop. There are two conditions I want to check for - if both are true I don't want to execute any code below the if condition, I just want to loop back to top increment my tIndex by 1 and then work my way down the loop if the condition is not met. I know I can block the code in an if -- end if, however I was looking at the way live code works - and came across the exit to top. Is that what it's not used for?

Thanks
Jalz

Code: Select all


repeat for each key tIndex in tGrid
      
      -- if its estimate and optional(label 4) don't continue with the code to go down the loop but reiterate after incrementing
      if (tHeader["Label"][1] is "Estimate") and (tGrid[tIndex]["Label 4"] is true) then exit to top
      
      put "PrintLines" & tIndex into tPrintLines

end repeat


Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: repeat loop - exit to top

Post by Klaus » Sun Feb 22, 2015 7:58 pm

Hi Jlaz,

not exactly sure what you are after, but "exit to top" will leave the current handler, that is correct.
Maybe you are looking for "exit repeat"? That will only leave, well, you guessed, the repeat loop. :D


Best

Klaus

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

Re: repeat loop - exit to top

Post by dunbarx » Sun Feb 22, 2015 9:29 pm

Hi,

Is it possible the "next repeat" is what you are looking for?

Craig Newman

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: repeat loop - exit to top

Post by jalz » Mon Feb 23, 2015 12:12 am

Thank you, ive got around it in an If then Else, but I believe next repeat was what I was looking for. Something to remember for the future :D

Post Reply