break instruction

A forum dedicated to George scripting questions
Post Reply
fazek
Posts: 24
Joined: 07 Feb 2016, 14:54

break instruction

Post by fazek »

I've tried to use the break keyword inside of loops and it seems break cannot abort the loop conditionally. I think it's because the if..end is also a code block for the break command:

Code: Select all

while (condition1)
    ...
    if (condition2)
        break            //break here
    end
    //break continues here
    ...
end
//and not here
Is this a real thing? Maybe I've missed something, is there a way to break the loop like in other languages?
If this is not possible, I may have an idea: add an optional argument for the break command, to jump through a given number of end statements. This is compatible with the previous behaviour and it's even better than the solutions of many other languages (it can jump out from embedded loops).

I mean this:

Code: Select all

while (condition1)
    ...
    if (condition2)
        break 2           //break here
    end
    ...
end
//break continues here
User avatar
Mike
Posts: 1050
Joined: 16 Feb 2006, 08:58

Re: break instruction

Post by Mike »

I think you will have to forget using the 'break' instruction :|
TVPaint Team
User avatar
schwarzgrau
Posts: 1238
Joined: 23 Jan 2012, 22:08
Location: Offenbach / Germany
Contact:

Re: break instruction

Post by schwarzgrau »

Is there some workaround to abort the loop ?
Windows 11 22H2 / TVP 11.7.0 PRO WIBU / Cintiq 22HD
Windows 11 22H2 / TVP 11.7.0 PRO WIBU / Mobile Studio Pro 16" (2019)
Android 13 / TVP 11.7.0 / Galaxy Tab 7 FE
INSTAGRAM
Svengali
Posts: 1571
Joined: 28 Dec 2006, 10:08

Re: break instruction

Post by Svengali »

schwarzgrau wrote:Is there some workaround to abort the loop ?
Using an "EXITFLAG" will do it...

Sven
TVP Pro 11.0.10-64bit Win10 - 64GB ram -2TB HHD - 256GB SSD - Wacom Cintiq 16, driver 6.3.41-1
Android Tablet: rel. 11, Samsung Galaxy Note10.1 - 32GB with microSD 32GB
Android Tablet: rel. 11.5, Samsung Galaxy Tab S7plus - 128GB with microSD 64GB
User avatar
schwarzgrau
Posts: 1238
Joined: 23 Jan 2012, 22:08
Location: Offenbach / Germany
Contact:

Re: break instruction

Post by schwarzgrau »

Thank you again Sven
Windows 11 22H2 / TVP 11.7.0 PRO WIBU / Cintiq 22HD
Windows 11 22H2 / TVP 11.7.0 PRO WIBU / Mobile Studio Pro 16" (2019)
Android 13 / TVP 11.7.0 / Galaxy Tab 7 FE
INSTAGRAM
Post Reply