DIV operator not working

The Wiki says that you can do integer division using the DIV operator, which I would expect to have syntax similar to the MOD operator but it doesn't work. E.g.,

Works

      `%Calculate%LocalScreen.Width MOD LocalColumns%`

Broken

      `%Calculate%LocalScreen.Width DIV LocalColumns%`

Of course, this can be easily worked around with

       `%Calculate%ROUND(LocalScreen.Width/LocalColumns)%`

But this looks like either a bug in the app or the docs (or my brain).

The DIV operator is working for me:
image

Running Keyboard Maestro 9.0.4 on macOS 10.14.6 (Mojave)

Must be some other syntax issue with your Action. Please post the actual Action that is not working for you.

As I showed above, "DIV" does work with explicit number.
But it fails with KM Variables:

TEST Use of DIV Operator @TEST Macro (v9.0.4)

TEST Use of DIV Operator @TEST.kmmacros (2.2 KB)

image

@peternlewis, I can confirm this as a bug.

It fails because "Width DIV XLocal__Columns" is a valid variable name.

Keyboard Maestro has special case code for detecting this occurrence, but unfortunately I missed the DIV case.

Fixed for the next version.

In the mean time, use parenthesis ( ).

(XLocal__Screen.Width) DIV (XLocal__Columns)
2 Likes

Thanks for all of the great tests and feedback. Looking forward to being more active here.

1 Like