Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in or
create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision |
Your text |
Line 1: |
Line 1: |
| This template is for code. The first argument is the title of the code block but can be left blank. | | This template is for code. The first argument is the title of the code block or text file. The actual code still needs to be inside a <nowiki><pre>...</pre></nowiki> block. |
|
| |
|
| * the actual code still needs to be inside a {{Codeline|<nowiki><pre> ... </pre></nowiki>}} block or a {{Codeline|<nowiki><syntaxhighlight> ... </syntaxhighlight></nowiki>}} block.
| | Example: |
| * to markup code that is the contents of specific files, use [[Template:File]] instead.
| | <pre>{{Code|input check example|<pre> |
| | | if (nargin < 1 || nargin > 4) |
| == Code ==
| | print_usage; |
| <pre> | | elseif (!isnumeric (arg1)) |
| {{Code | | error ("first argument should be numeric"); |
| |Title= | | endif |
| |Code= | | </pre>}}</pre> |
| }}
| |
| </pre> | |
| You can omit the parameters if you respect the correct order.
| |
| | |
| == Examples ==
| |
| === Example 1 ===
| |
| <pre>{{Code|input check example|
| |
| if (nargin < 1 || nargin > 4) | |
| print_usage; | |
| endif | |
| }}</pre> | |
|
| |
|
| Will produce: | | Will produce: |
| {{Code|input check example| | | {{Code|input check example|<pre> |
| if (nargin < 1 || nargin > 4) | | if (nargin < 1 || nargin > 4) |
| print_usage; | | print_usage; |
| endif | | elseif (!isnumeric (arg1)) |
| | error ("first argument should be numeric"); |
| | endif |
| </pre>}} | | </pre>}} |
| | | <noinclude>[[Category:Template Documentation]]</noinclude> |
| === Example 2 ===
| |
| Note the empty code description.
| |
| <pre>{{Code| | |
| |x (x > 20) = 34;
| |
| }}</pre>
| |
| | |
| Will produce:
| |
| {{Code|
| |
| |x (x > 20) = 34;
| |
| }}
| |
| | |
| === Example 3 ===
| |
| <pre>
| |
| {{Code
| |
| |Title = input check example
| |
| |Code = if (nargin < 1 || nargin > 4)
| |
| print_usage;
| |
| endif
| |
| }}
| |
| </pre>
| |
| | |
| Will produce:
| |
| {{Code
| |
| |Title = input check example
| |
| |Code = if (nargin < 1 || nargin > 4)
| |
| print_usage;
| |
| endif
| |
| }}
| |
| | |
| === Example 4 ===
| |
| <pre>
| |
| {{Code
| |
| |Title =
| |
| |Code = if (nargin < 1 || nargin > 4)
| |
| print_usage;
| |
| endif
| |
| }}
| |
| </pre>
| |
| | |
| Will produce:
| |
| {{Code
| |
| |Title =
| |
| |Code = if (nargin < 1 || nargin > 4)
| |
| print_usage;
| |
| endif
| |
| }}
| |
| | |
| [[Category:Template with documentation]] | |