jeff
Full Member
 
Posts: 15
|
Post by jeff on Sept 22, 2020 1:05:16 GMT
How do you do simple math in MMM? I am trying to add 1 to an int and then divide it by 2. This doesn't seem to work easily in MMM. I even struggle to define int2 based on int1 and a constant. For instance 1 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER1%::3
2 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER2%::+1%INTEGER1% Gives me 13 instead of two. And putting the 1 at the end gives me 31.
I've also tried chaining variables together via the 7.4 update i.e.
1 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER%::3 2 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER1%::1 3 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER2%::+%INTEGER%+%INTEGER1% 5 | RUN ACTION | MESSAGE PROMPT | %INTEGER2%::::0 but that just throws me an error.
|
|
|
Post by Steve on Sept 22, 2020 10:12:40 GMT
Hi jeff How do you do simple math in MMM? I am trying to add 1 to an int and then divide it by 2. This doesn't seem to work easily in MMM. I even struggle to define int2 based on int1 and a constant. For instance 1 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER1%::3 2 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER2%::+1%INTEGER1% Prior to a macro line being executed any variables that are used in the line are converted to its value. Your line 1 declares INTEGER1 as 3 and at line 2 we are essentially doing this: RUN the ACTION to DEFINE the INTEGER VARIABLE of INTEGER2 to +13So the results is going to be INTEGER2 + 13. If INTEGER2 is 0 (undefined) then 0+13=13. How do you do simple math in MMM? I am trying to add 1 to an int and then divide it by 2. This doesn't seem to work easily in MMM. Simple math is done like this: Define Variable INTEGER (9=9) 1 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER%::9 Add 1 to an INT (9+1=10) 2 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER%::+1 Divide it by 2 (10/2=5) 3 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER%::/2 I've also tried chaining variables together via the 7.4 update i.e. 1 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER%::3 2 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER1%::1 3 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER2%::+%INTEGER%+%INTEGER1% 5 | RUN ACTION | MESSAGE PROMPT | %INTEGER2%::::0 but that just throws me an error.
The line 3 syntax should be this: 3 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER2%::+%INTEGER%::+%INTEGER1% But that doesn't seem to be working as expected. I'll have a look at the source code and figure out why. You've found a bug, thanks for pointing that out.
I hope this helps.
|
|
|
Post by Chaba on Dec 3, 2020 21:23:02 GMT
Has this been fixed? I'm running version 8.0 and can't seem to get any of the chaining to work properly (it only evaluates the first value). Thanks
|
|
|
Post by Steve on Dec 5, 2020 1:23:53 GMT
Has this been fixed? I'm running version 8.0 and can't seem to get any of the chaining to work properly (it only evaluates the first value). Thanks No sorry it hasn't. It's going to be with the next update. I will be dropping a minor update before the end of year. I've logged an internal bug BZ for it here MMM_BZ4 (https://www.turnssoft.com/bugtrack.html#bugs). Edit - I've fixed the issue in the code today. It's been added to "Fixes" minimousemacro.proboards.com/thread/278/update-coming-next-mouse-macro
|
|
|
Post by Chaba on Dec 6, 2020 21:35:30 GMT
Great! This app just gets better and better. Thanks for your hard work.
|
|
|
Post by Chaba on Feb 13, 2021 21:31:55 GMT
Hey Steve, thanks for the 8.1 update! I see that now my code is working for the chaining math with integer variables, but it seems to still be broken for the decimal variables. For example, if I type: 1 | RUN ACTION | DEFINE DECIMAL VARIABLE | %DECIMAL%::3::*2
2 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER%::3::*2 DECIMAL evaluates to 3, while integer evaluates to 6.
|
|
|
Post by Steve on Feb 14, 2021 7:26:50 GMT
Hey Steve, thanks for the 8.1 update! I see that now my code is working for the chaining math with integer variables, but it seems to still be broken for the decimal variables. For example, if I type: 1 | RUN ACTION | DEFINE DECIMAL VARIABLE | %DECIMAL%::3::*2
2 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER%::3::*2 DECIMAL evaluates to 3, while integer evaluates to 6. Ah yep. Looks like I missed that one. I've added it to the bug list as MMM_BZ18. I'll look into fixing it for the next update.
|
|