Set Digital icon Set Digital Toggle a digital I/O port between TTL low (0V) and high (3.3V/5V) in ARC; select board and port, simple on/off control-signal only. Try it →
USA
Asked — Edited
Resolved Resolved by DJ Sures!

Expression Parser Broken: Boolean Expressions With Negative Numbers

The code below does not work:


1: ClearVariables() 
2: $status = -1
3: $retry = 3
4: if ($retry<3 AND $status<0)
5:   #do something
6: endif

error:

Quote:

Error on line 4: Missing String Quotes or Invalid Expression at index 8: -


ARC Pro

Upgrade to ARC Pro

Stay at the forefront of robot programming innovation with ARC Pro, ensuring your robot is always equipped with the latest advancements.

Author Avatar
PRO
USA
#1  

the code works when the status variable has a non negative number.

Author Avatar
PRO
USA
#2  

RepeatWhile and RepeatUntil are also affected

Author Avatar
PRO
USA
#3  

this was the initial code (stops working when status is negative)


repeatwhile($retry>0 AND $status<0)
  print("Do something here")
  $retry = $retry - 1
endrepeatwhile 
Author Avatar
PRO
USA
#4  

to overcome the bug, i end up changing the logic and the code became more complex to read.


:loop
if ($retry>0)
  if ($status<0)
    Print("Do something here")
    $retry = $retry -1
    Goto(loop)
  endif
endif
#5  

These variations seem to work:


if ($retry<3) AND ($status<0)
           or
if (($retry<3) AND ($status<0))

repeatwhile(($retry>0) AND ($status<0))
Author Avatar
PRO
Synthiam
LinkedIn Thingiverse Twitter YouTube GitHub
#6  

fixed in next release

Author Avatar
PRO
Synthiam
LinkedIn Thingiverse Twitter YouTube GitHub
#7  

PS - also, thanks for the examples @WBS and @ptp . It helps identify the solution with use case examples. Usually someone just says "this doesn't work" and i have to guess what they were trying to do:D

Author Avatar
PRO
USA
#8  

Thanks