Skip to content

Formatting

Info

New in Atfinity 17.

Atfinity can rewrite the layout of a rule without changing what it does: one space around the operators that combine values, p.age and the like left untouched, each branch of an if on its own line, and a consistent indentation. A minus that negates a value stays next to it, as in -1.

A rule Atfinity cannot read, or one the formatter cannot rewrite without changing its meaning or losing a comment, is left exactly as it is.

The whole configuration

Format All RuLa Code, on the RuLa and References page, first tells you how many rules it would change and names every rule it cannot rewrite, with the reason. Once you confirm, it writes into your draft, so the result reaches cases with your next Put Live. Two of the fields the page lists stay outside what it rewrites: the environment constants, which belong to the environment rather than to the draft, and a document box reference, which the formatter cannot respace without breaking it. The page still lists and searches both, and marks them as fields it does not cover. When one of them is badly formatted, the dialog names it rather than reporting that everything is already formatted.

A single rule

Right clicking in any RuLa editor formats the rule you are editing. The rewrite goes into the editor rather than into your draft, so it reaches cases only once you save the rule and put the draft live. A rule the formatter cannot rewrite is left as it is, with no message.

What happens to comments

Comments are never lost, but only one that already sits on its own line stays where it is. A comment sharing a line with code moves onto its own line, and can travel to the end of the statement it sat in:

if p.age > 18 then 'adult' # the legal age
else 'minor' end

becomes

if p.age > 18 then
    'adult'
else
    'minor'
end
# the legal age

Move such a comment above the statement before you format, or it will read as if it explained the whole rule.