USA
Asked — Edited

Function Request - Modulo Operation

@DJ,

For the next release, can you please add:

  1. Modulus Function e.g. Mod( Number1, Number2 ) OR
  2. Modulus operator e.g. Number1 % Number2

I know you can use plugins to add custom functions, but they don't work on mobile applications.

Modulus is so versatile and useful deserves a place in EZ-Script.

Simple examples:

1)


$counter=0
:loop
#do something
if (Mod($counter,100)=0)
   print("Debug info")
endif
Sleep(100)
$counter=$counter+1
Goto(loop)


#calculate the difference between $angle1 and $angle0
$diff=Abs( Mod($angle0+180-$angle1, 360) - 180)


ARC Pro

Upgrade to ARC Pro

Elevate your robot's capabilities to the next level with Synthiam ARC Pro, unlocking a world of possibilities in robot programming.

PRO
Synthiam
#1  

Use the % like C and other programming languages.


repeat($x, 1, 50, 1)

print( $x % 10)

endrepeat

Outputs:

Quote:

Start 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 Done (00:00:00.2248864)

PRO
USA
#2  

I missed that one

i tried before


print ($b % $a)

I got an error but it's the space between the (. So i assumed didn't existed

Thanks

PRO
Synthiam
#3  

Roger:D

I might make a global option one day to allow no spaces between functions. But i added space requirements two years or so ago to force users to format their code for readability. There were crazy scripts with issues reported because users couldn't understand their own formatting. So now it's mandatory to format with spaces and the number of users posting script assistance has dramatically reduced. The result is that it is much easier to read with spaces rather than one mess without:D