The eccoMAGIC Forums
http://forums.eccoMAGIC.com/forum/YaBB.pl
the SLANG EXTENSION and Guest Programming >> Slang Rules Scripts, Functions, Examples and HOW TO >> 'Complex' Math Expressions for Rules
http://forums.eccoMAGIC.com/forum/YaBB.pl?num=1487222612

Message started by Admin on 02/15/17 at 23:23:32

Title: 'Complex' Math Expressions for Rules
Post by Admin on 02/15/17 at 23:23:32




In LUA scripts you can use the LUA math (including from the math module).  So modulo is simple in LUA,  e.g., "%".

But how to do stuff like that in simple slang rules ?


Absolute Value


Code:
iff([Base] < 0,0 - [Base],[Base])




MODULO:


Code:
++::replace((0 + replace((iff([Base] < 0,0 - [Base],[Base]) /7.0),"\d+(?=\.)","") + 0.01) * 7.0,"\.\d+",""):[Base] <> ""




notes:

Condition of [Base] would ignore value when zero, so we use a text compare <> blank

This example is modula for 7.  Use 7".0" to force decimal in result, even if 7 % 7.


The eccoMAGIC Forums » Powered by YaBB 2.1!
YaBB © 2000-2005. All Rights Reserved.