Function Request - Modulo Operation

 
#1

@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)

Code:


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



2)

Code:


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

#2

Use the % like C and other programming languages.

Code:


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)

#3

I missed that one

i tried before

Code:


print ($b % $a)



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

Thanks

#4

Roger Grin

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 Grin