
ptp
@DJ,
The ElseIf is broken:
The code below never stops !Code:
$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.Code:
$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 ?
I tried the simplest
If
ElseIF
EndIf
I could think of and this is working both trying $a=1 and $a=2
Code:
I'm using ARC 2017.05.14
Maybe the ElseIf issue has been fixed
Regards,
Frank
Did you tried my code and is working for you ?
I just tried my code with the new version and the bug is still present.
Simple example 2 (broken):
Code:
output:
script does not stop and keeps printing "Start".
Simple example 3 (broken) WORKING:
Code:
output:
Start
***Start
another number
End
#EDIT: This example works, Start is not duplicated, i confused the second start with ARC Start
didn't took me long to break your code
Code:
The code above is broken
Last version ?
You are right! I forgot to check the boundary conditions..
$A=3 breaks it with the latest ARC
I get the same "Start" message that you do
Thanks,
Frank
Code:
Outputs (correct):
----------------------------------------------------------------------------------------------
Code:
Outputs (correct):
------------------------------------------------------------------------------------------------------
Code:
Outputs (correct):
It's fixed in your version ? Current version does not work.
Your examples are all incorrect - surprised none of you caught any of the incorrectness
If you copy and paste my code into your copy of ARC, you will receive the same output. Copy and paste, do not type it because there's lots of mistakes being made in this thread example code. Such as the $a=11 lol
What is the mistake in the code below ?
Code:
the code above produces this:
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
Not in this tutorial:
https://www.ez-robot.com/Tutorials/UserTutorials/134/1
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
it seems the problem is when the condition is false and no else is found.
OK:
Code:
if you change the condition:
Code:
it get lost forever:
Code:
Outputs: