Browse the docs

oct

Reads text as an octal number and returns it as an ordinary number.

Keyboard Maestro: OCT

Details #

oct(text) takes exactly one argument and returns a number. The argument is read as text in base 8 (octal), so oct("17") is 15.

Spaces around it are ignored, capitals and small letters both work, and a 0x, 0b or 0o prefix is dropped. A leading minus sign is allowed. To go the other way, use formatBase.

Parameters #

Takes 1 argument. {{ oct(text) }}

Examples #

oct("17")
→ 15
oct(code)
→ 493
Sample variableValue
code755

Gotchas #

  • Calling it with no argument or more than one is an error: oct() takes 1 argument, got 2.

  • Text that isn't an octal number stops the step: oct() needs a octal number, got "zz" (showing the first 20 characters it was given).

  • A number argument is turned into text first, so oct(10) reads the digits "10", not the value ten.

  • Only whole numbers are read; a decimal point is an error.