Commit 8148d590 authored by Fabrice Salvaire's avatar Fabrice Salvaire

doc cleanup

parent 4f20b8df
......@@ -2,7 +2,7 @@ O Codes
=======
O-codes provide for flow control in NC programs. Each block has an associated number, which is the
number used after O. Care must be taken to properly match the O-numbers. O codes use the letter 'O'
number used after O. Care must be taken to properly match the O-numbers. O codes use the letter ``O``
not the number zero as the first character in the number like O100 or o100.
Numbering
......@@ -42,8 +42,8 @@ The behavior is undefined if:
Subroutines
-----------
Subroutines starts at 'Onnn sub' and ends at 'Onnn endsub'. The lines between 'Onnn sub' and 'Onnn
endsub' are not executed until the subroutine is called with 'Onnn call'. Each subroutine must use a
Subroutines starts at ``Onnn sub`` and ends at ``Onnn endsub``. The lines between ``Onnn sub`` and ``Onnn
endsub`` are not executed until the subroutine is called with ``Onnn call``. Each subroutine must use a
unique number.
Subroutine Example
......@@ -63,8 +63,8 @@ information.
O- Return
Inside a subroutine, 'O- return' can be executed. This immediately returns to the calling code, just
as though 'O- endsub' was encountered.
Inside a subroutine, ``O- return`` can be executed. This immediately returns to the calling code, just
as though ``O- endsub`` was encountered.
O- Return Example
......@@ -85,12 +85,12 @@ for more information.
O- Call
'O- Call' takes up to 30 optional arguments, which are passed to the subroutine as '#1', '#2' , …​,
``O- Call`` takes up to 30 optional arguments, which are passed to the subroutine as ``#1``, ``#2`` , …​,
#N. Parameters from #N+1 to #30 have the same value as in the calling context. On return from the
subroutine, the values of parameters #1 through #30 (regardless of the number of arguments) will be
restored to the values they had before the call. Parameters #1 - #30 are local to the subroutine.
Because '1 2 3' is parsed as the number 123, the parameters must be enclosed in square brackets. The
Because ``1 2 3`` is parsed as the number 123, the parameters must be enclosed in square brackets. The
following calls a subroutine with 3 arguments:
O- Call Example
......@@ -113,14 +113,14 @@ Subroutine bodies may not be nested. They may only be called after they are defi
called from other functions, and may call themselves recursively if it makes sense to do so. The
maximum subroutine nesting level is 10.
Subroutines do not have 'return values', but they may change the value of parameters above #30 and
Subroutines do not have ``return values``, but they may change the value of parameters above #30 and
those changes will be visible to the calling code. Subroutines may also change the value of global
named parameters.
Fanuc-Style Numbered Programs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Numbered programs (both main and subprograms), the 'M98' call and 'M99' return M-codes, and their
Numbered programs (both main and subprograms), the ``M98`` call and ``M99`` return M-codes, and their
respective semantic differences are an alternative to the rs274ngc subroutines described above,
provided for compatibility with Fanuc and other machine controllers.
......@@ -149,7 +149,7 @@ but this has no special meaning in the rs274ngc interpreter.
Call a numbered subprogram. The block ``M98 P100`` is analogous to the traditional ``o100 call``
syntax, but may only be used to call a following numbered subprogram defined with ``o100``\ …​\
``M99``. An optional 'L'-word specifies a loop count.
``M99``. An optional ``L``-word specifies a loop count.
``M30``
......@@ -182,7 +182,7 @@ The ``M98`` subprogram call differs from rs274ngc ``O call`` in the following wa
``M98 L0`` block will not execute the subprogram.
In rare cases, the ``M99`` M-code may be used to terminate the main program, where it indicates an
'endless program'. When the interpreter reaches an ``M99`` in the main program, it will skip back to
``endless program``. When the interpreter reaches an ``M99`` in the main program, it will skip back to
the beginning of the file and resume execution at the first line. An example use of an endless
program is in a machine warm-up cycle; a block delete program end ``/M30`` block might be used to
stop the cycle at a tidy point when the operator is ready.
......@@ -219,10 +219,10 @@ and ``O200``, its value will equal ``5.25``.
Looping
-------
The 'while loop' has two structures: 'while/endwhile', and 'do/while'. In each case, the loop is
exited when the 'while' condition evaluates to false. The difference is when the test condition is
done. The 'do/while' loop runs the code in the loop then checks the test condition. The
'while/endwhile' loop does the test first.
The ``while loop`` has two structures: ``while/endwhile``, and ``do/while``. In each case, the loop is
exited when the ``while`` condition evaluates to false. The difference is when the test condition is
done. The ``do/while`` loop runs the code in the loop then checks the test condition. The
``while/endwhile`` loop does the test first.
While Endwhile Example
......@@ -257,24 +257,24 @@ Do While Example
(msg, Loop Done!)
M2
Inside a while loop, 'O- break' immediately exits the loop, and 'O- continue' immediately skips to
the next evaluation of the 'while' condition. If it is still true, the loop begins again at the
Inside a while loop, ``O- break`` immediately exits the loop, and ``O- continue`` immediately skips to
the next evaluation of the ``while`` condition. If it is still true, the loop begins again at the
top. If it is false, it exits the loop.
Conditional
-----------
The 'if' conditional consists of a group of statements with the same 'o' number that start with 'if'
and end with 'endif'. Optional 'elseif' and 'else' conditions may be between the starting 'if' and
the ending 'endif'.
The ``if`` conditional consists of a group of statements with the same ``o`` number that start with ``if``
and end with ``endif``. Optional ``elseif`` and ``else`` conditions may be between the starting ``if`` and
the ending ``endif``.
If the 'if' conditional evaluates to true then the group of statements following the 'if' up to the
If the ``if`` conditional evaluates to true then the group of statements following the ``if`` up to the
next conditional line are executed.
If the 'if' conditional evaluates to false then the 'elseif' conditions are evaluated in order until
one evaluates to true. If the 'elseif' condition is true then the statements following the 'elseif'
up to the next conditional line are executed. If none of the 'if' or 'elseif' conditions evaluate to
true then the statements following the 'else' are executed. When a condition is evaluated to true no
If the ``if`` conditional evaluates to false then the ``elseif`` conditions are evaluated in order until
one evaluates to true. If the ``elseif`` condition is true then the statements following the ``elseif``
up to the next conditional line are executed. If none of the ``if`` or ``elseif`` conditions evaluate to
true then the statements following the ``else`` are executed. When a condition is evaluated to true no
more conditions are evaluated in the group.
If Endif Example
......@@ -301,7 +301,7 @@ If ElseIf Else EndIf Example
F150
o102 endif
Several conditons may be tested for by 'elseif' statements until the 'else' path is finally executed
Several conditons may be tested for by ``elseif`` statements until the ``else`` path is finally executed
if all preceding conditons are false:
If Elseif Else Endif Example
......@@ -322,7 +322,7 @@ If Elseif Else Endif Example
Repeat
------
The 'repeat' will execute the statements inside of the repeat/endrepeat the specified number of
The ``repeat`` will execute the statements inside of the repeat/endrepeat the specified number of
times. The example shows how you might mill a diagonal series of shapes starting at the present
position.
......@@ -362,8 +362,8 @@ Calling Files
-------------
To call a separate file with a subroutine name the file the same as your call and include a sub and
endsub in the file. The file must be in the directory pointed to by 'PROGRAM_PREFIX' or
'SUBROUTINE_PATH' in the ini file. The file name can include **lowercase** letters, numbers, dash,
endsub in the file. The file must be in the directory pointed to by ``PROGRAM_PREFIX`` or
``SUBROUTINE_PATH`` in the ini file. The file name can include **lowercase** letters, numbers, dash,
and underscore only. A named subroutine file can contain only a single subroutine definition.
Named File Example
......@@ -396,7 +396,7 @@ Called File Example
Subroutine return values
------------------------
Subroutines may optionally return a value by an optional expression at an 'endsub' or 'return'
Subroutines may optionally return a value by an optional expression at an ``endsub`` or ``return``
statement.
Return value example
......@@ -407,9 +407,9 @@ Return value example
...
o123 endsub [3 * 4]
A subroutine return value is stored in the '<_value>' `predefined named parameter
<#gcode:predefined-named-parameters>`__ , and the '<_value_returned>' predefined parameter is set to
1, to indicate a value was returned. Both parameters are global, and are cleared just before the
A subroutine return value is stored in the ``<_value>`` `predefined named parameter
<#gcode:predefined-named-parameters>`__ , and the ``<_value_returned>`` predefined parameter is set
to 1, to indicate a value was returned. Both parameters are global, and are cleared just before the
next subroutine call.
Errors
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment