|
Post by zeak on Jan 20, 2020 0:26:13 GMT
Hi All,
I need a way to work out if a INTEGER VARIABLE is a leap year.
for example i would type 20 for 2020, then determine if that would be a leap year. if so output a BOOLEAN yes.
Any Ideas are welcome.
Cheers, Zeak
|
|
|
Post by Steve on Jan 20, 2020 1:38:51 GMT
|
|
|
Post by Steve on Jan 20, 2020 4:49:28 GMT
The modulus function can do this: 1 | RUN ACTION | DEFINE BOOLEAN VARIABLE | %BOOLEAN%::FALSE 2 | RUN ACTION | INPUT BOX | Enter the number:::Leap year::INTEGER 3 | IF | INTEGER VARIABLE | %INTEGER% | % | 4::=::0 | DEFINE BOOLEAN VARIABLE | %BOOLEAN%::TRUE 4 | IF | BOOLEAN VARIABLE | %BOOLEAN% | IS TRUE | MESSAGE PROMPT | BOOL is %boolean%::Boolean True::1 | ELSE | 3 | RUN ACTION | MESSAGE PROMPT | BOOL is %boolean%::Boolean False::1
|
|
|
Post by zeak on Jan 20, 2020 5:58:10 GMT
well that's a lot easier then what I came up with lol. 1 | RUN ACTION | INPUT BOX | Is number Divisible by 4::4::INTEGER 2 | IF | INTEGER VARIABLE | %INTEGER% | IS | | STOP 3 | RUN ACTION | DEFINE DECIMAL VARIABLE | %DECIMAL%::%INTEGER% 4 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER%::/4 5 | RUN ACTION | DEFINE DECIMAL VARIABLE | %DECIMAL%::/4 6 | RUN ACTION | DEFINE INTEGER VARIABLE | %DECIMAL%::-%INTEGER% 7 | IF | DECIMAL VARIABLE | %DECIMAL% | IS NOT | 0 | DEFINE BOOLEAN VARIABLE | %BOOLEAN%::0 8 | IF | DECIMAL VARIABLE | %DECIMAL% | IS | | DEFINE BOOLEAN VARIABLE | %BOOLEAN%::1 9 | RUN ACTION | MESSAGE PROMPT | %BOOLEAN%::::0 10 | RUN ACTION | GOTO MACRO LINE | 1 I ended up comparing a INTEGER and DECIMAL variable because I knew that integer wouldn't return the decimal.
|
|
|
Post by zeak on Jan 20, 2020 6:05:05 GMT
Gotta ask, you know the Line number after the ELSE. Is there anyway we can remove these?? Its just I not like do the ELSE OR AND because these numbers don't update with relist rows.
|
|
|
Post by Steve on Jan 20, 2020 8:44:50 GMT
The ELSE number yeah i don't like it either. it shouldn't be there or it should match the current line number.
The ELSE number is there because the the ELSE statement evaluates as a complete line, and a complete line needs a starting line number
It can be 'X'd out: True::1 | ELSE | X | RUN ACTION | MESSAGE PROMPT | BOOL is %boolean%::Boolean False::1 But it has to be there unfortunately. Its kinda baked in to the code.
|
|
|
Post by Steve on Jan 20, 2020 8:59:07 GMT
1 | RUN ACTION | ADD MACRO FROM URL | https://pastebin.com/raw/k0EKJUqd
|
|
|
Post by cyberchipz on Feb 9, 2020 18:33:11 GMT
Hmm, could you code MMMPro to use LABEL1, and on run build a table of line numbers which are variables with %LABEL1% where on run, %LABEL1% is assigned a line number? Would slow run time a bit in a lengthy program; but, could then use labels, up to 99 of them. :-)
Oooh! When do we get an event log with all those features?! :-)
|
|
|
Post by zeak on Feb 9, 2020 22:12:38 GMT
Hmm, could you code MMMPro to use LABEL1, and on run build a table of line numbers which are variables with %LABEL1 % where on run, %LABEL1% is assigned a line number? Would slow run time a bit in a lengthy program; but, could then use labels, up to 99 of them. :-) Oooh! When do we get an event log with all those features?! :-) Hi Cyberchipz, Can you please explain more of what you mean, as I can't seem to understand it in the context of this thread.
|
|
|
Post by cyberchipz on Feb 12, 2020 16:28:39 GMT
Sorry zeak... got an idea mixed up with reading other threads, and picked the wrong post to comment. 8-o My apologies. I was thinking about a possible feature for MMM using labels for goto that could be pretty simple to incorporate... in fact, it might even be able to be scripted... I'll start a thread.
the event log comment was just a part of MMM's event log I hadn't seen yet. (IOW, an embarrassing noob comment). lol
|
|