Closed Asd-g closed 5 months ago
(Just acknowledging your request) I hope it won't be difficult. Just for the note, Avisynth loops are basically unrolled ones.
gee, I found in the source that break
is already implemented
After a quick 'continue' implementation, it turned out that - at present implementation - break
is ignoring the preceeding commands in loop. So the following example won't display "First statement in loop 4", neither "We'll break at 4". This must be healed as well. Until I commit the continue
addition, simply comment those lines out to see what I mentioned.
ColorBars()
for (i=1, 6) {
SubTitle(Format("First statement in loop {i}"), x=0, y=i*20)
if(i == 4) {
SubTitle(Format("We'll break at {i}"), x=200, y=i*20)
break
}
if(i == 2) {
SubTitle(Format("continue at {i}"), x=200, y=i*20)
continue
}
SubTitle(Format("Final statement in loop {i}"), x=300, y=i*20)
}
Actual test script
ColorBars()
for (i=1, 6) {
SubTitle(Format("statement_1 i={i}"), x=0, y=i*20)
SubTitle(Format("statement_2 i={i}"), x=140, y=i*20)
if(i == 4) {
SubTitle(Format("Break at i={i}"), x=280, y=i*20)
break
}
SubTitle(Format("statement_3 i={i}"), x=280, y=i*20)
if(i == 2) {
SubTitle(Format("Continue at i={i}"), x=420, y=i*20)
continue
}
SubTitle(Format("Final statement in i={i}"), x=420, y=i*20)
}
SubTitle(Format("Outside"), x=0, y=7*20)
And the expected output:
statement_1 i=1 statement_2 i=1 statment_3 i=1 Final statement in i=1
statement_1 i=2 statement_2 i=2 statment_3 i=2 continue at i=2
statement_1 i=3 statement_2 i=3 statment_3 i=3 Final statement in i=3
statement_1 i=4 statement_2 i=4 Break at i=4
Outside
See also commit 4014f8f7ca85d8b0c45485611eb2d4f7b52e95f1 for fixing the above mentioned break behavior.
Documentation will be updated after it's considered to be working. @Asd-g: should I make a build for you to test (I guess, not :) )
Thanks for the quick implementation.
It works without issues.
Your welcome. Document updates are available online: https://avisynthplus.readthedocs.io/en/latest/avisynthdoc/syntax/syntax_control_structures.html#using-break-and-continue-in-loops
It will be very good if there are c/cpp like
continue
andbreak
in loop blocks.