Syntax of algorithms in User Macros

From Protoi Healing

Jump to: navigation, search

Draft collection:

  • All KEYWORDS are written caps and bold.
  • All methods use the template {{Method|}}, which means currently green and bold.
  • All 'variables' are capsuled in '...'.
  • All <parameters> and all {options} are written in italic.
  • All comments use the template {{Comment|}}, which means currently dark-blue, bold and italic.
  • Algorithms are written as a numbered list, using numbered list formatting (See here).
    This produces the result of each line starting with a number, for easy reference.
  • Certain Keywords, such as IF and LOOP, are immediately followed by increasing the indent level on the next line.
    • For example: if a line contains an IF keyword, the next line should be indented one further level than its preceding line. The new indent level will remain until the corresponding IF-END keyword appears (which should be written on the same indent level as its matching IF keyword).
    • The indent level may be further increased with additional IF or LOOP or similar keywords.
    • Increasing indentation level after IF keywords (or similar) makes the algorithm's logic easier to follow, as sections inside IF keywords or LOOPs are visually distinct from the rest of the code.
    • Lines which have an indent level greater than the first line of the algorithm are numbered by following the trail of indents and joining together all the corresponding line numbers.
      For example: if line 20 contains an IF keyword, soon to be followed by another IF keyword three lines later (on line 20.3), and a third IF keyword five lines after that (on line 20.3.5), the next line would be line, or ""
  • IF keywords and their corresponding IF-END keywords should be located on the same indentation level.
    This also applies to other keywords which are followed by an indent increase, such as "LOOP" - the corresponding "LOOP-END" should be on the same indent level as its matching "LOOP" keyword.