- This wiki is out of date, use the continuation of this wiki instead
Function
From FenixWiki
(Difference between revisions)
Revision as of 21:34, 7 May 2007 (edit) 84.82.73.239 (Talk) (→Example) ← Previous diff |
Current revision (23:26, 1 October 2007) (edit) (undo) Sandman (Talk | contribs) |
||
(3 intermediate revisions not shown.) | |||
Line 2: | Line 2: | ||
[[Category:reserved]] | [[Category:reserved]] | ||
[[Category:language]] | [[Category:language]] | ||
+ | [[category:basic statement]] | ||
+ | |||
+ | [[Basic statements|'''Up to Basic Statements''']] | ||
+ | |||
+ | [[:Category:functions|'''List of Functions''']] | ||
+ | ---- | ||
+ | |||
== Definition == | == Definition == | ||
- | A function is a [[subroutine]] to which one or more of the following apply:<br /> | ||
- | *it receives [[parameters]]<br /> | ||
- | *it acts on the parameters<br /> | ||
- | *it processes [[data]] located elsewhere<br /> | ||
- | *it [[return]]s a [[value]]<br /> | ||
- | A function | + | === Statement === |
+ | '''Function''' <returntype> <name>([<parameters>]); | ||
+ | |||
+ | Function is a reserved word used to start the code of a function. | ||
+ | |||
+ | === Concept === | ||
+ | A function is a [[subroutine]] to which one or more of the following apply: | ||
+ | *it receives [[parameters]] | ||
+ | *it acts on the parameters | ||
+ | *it processes [[data]] located elsewhere | ||
+ | *it [[return]]s a [[value]] | ||
- | + | The difference between a function and a [[process]] is that the calling process or function waits until the function is completed. When a process or function calls a process, it doesn't wait. This means that, even when the called function contains [[frame]] statements, the calling function or process still waits for the function to finish. This is shown in [[Tutorial:Textinput|this tutorial]]. | |
For a list of functions, see [[:Category:functions|this list of functions]]. | For a list of functions, see [[:Category:functions|this list of functions]]. | ||
Line 18: | Line 30: | ||
== Example == | == Example == | ||
<pre> | <pre> | ||
- | int addInts( int a , int b ) | + | Function int addInts( int a , int b ) |
- | Begin | + | Private // Declare private variables here |
+ | Begin // Start the main functioncode | ||
return a+b; | return a+b; | ||
- | End | + | End // End the main functioncode |
</pre> | </pre> | ||
addInts(3,6); will return 9. One can see that the function does indeed: | addInts(3,6); will return 9. One can see that the function does indeed: |
Current revision
Contents |
[edit] Definition
[edit] Statement
Function <returntype> <name>([<parameters>]);
Function is a reserved word used to start the code of a function.
[edit] Concept
A function is a subroutine to which one or more of the following apply:
- it receives parameters
- it acts on the parameters
- it processes data located elsewhere
- it returns a value
The difference between a function and a process is that the calling process or function waits until the function is completed. When a process or function calls a process, it doesn't wait. This means that, even when the called function contains frame statements, the calling function or process still waits for the function to finish. This is shown in this tutorial.
For a list of functions, see this list of functions.
[edit] Example
Function int addInts( int a , int b ) Private // Declare private variables here Begin // Start the main functioncode return a+b; End // End the main functioncode
addInts(3,6); will return 9. One can see that the function does indeed:
- receive parameters.
- act on the parameters.
- return a value.