
ptp
USA
Asked
— Edited
@DJ,
The ElseIf is broken:
The code below never stops !
$buffer="[123 456 789]"
$len=Length($buffer)
$ix=0
$start=-1
$end=-1
repeatwhile($ix<$len)
$ch=GetCharAt($buffer, $ix)
if ($ch="[")
print("found start")
$start=$ix
elseif ($start>=0 AND $ch="]")
print("found end")
$end=$ix
# break
$ix=$len+1
endif
print("increment ix")
$ix=$ix+1
endrepeatwhile
print($ix)
print($start)
print($end)
if you remove the ElseIf it works as expected.
$buffer="[123 456 789]"
$len=Length($buffer)
$ix=0
$start=-1
$end=-1
repeatwhile($ix<$len)
$ch=GetCharAt($buffer, $ix)
if ($ch="[")
print("found start")
$start=$ix
endif
if ($start>=0 AND $ch="]")
print("found end")
$end=$ix
# break
$ix=$len+1
endif
print("increment ix")
$ix=$ix+1
endrepeatwhile
print($ix)
print($start)
print($end)
This bug must be recent, i've used before the ElseIf, or did i miss something ?
Let me take a look and see how this can be... stay tuned
An IF or ELSEIF needs an ELSE to finish the clause before the ENDIF.
You can make the ELSE do nothing, but it is still required (at least in EZ-Script. Might be implied in some languages).
Not sure this has always been the case, but it is the difference between the failing and the succeeding cases.
Alan
@Alan,
Not in this tutorial: https://synthiam.com/Community/Tutorials/134/1
@ptp
Yeah, I edited my post to say I am not sure this has always been the case, but is the difference between the working and failing code. Was to point DJ towards cause of bug, not to say scripts were wrong.
Alan
yes i agree with you.
it seems the problem is when the condition is false and no else is found.
OK:
if you change the condition:
it get lost forever:
Fixed for next release (later tonight)...
Outputs:
Here you go: https://synthiam.com/Community/Questions/10370