- This wiki is out of date, use the continuation of this wiki instead
Local variable
From FenixWiki
(Difference between revisions)
Revision as of 16:57, 25 July 2007 (edit) Sandman (Talk | contribs) ← Previous diff |
Current revision (11:02, 1 March 2008) (edit) (undo) Sandman (Talk | contribs) m (→Example) |
||
(5 intermediate revisions not shown.) | |||
Line 1: | Line 1: | ||
[[Category:variablecategories]] | [[Category:variablecategories]] | ||
+ | [[category:general]] | ||
== Definition == | == Definition == | ||
A local variable is a [[variable]] that is specific to a [[process]] in the same way as a [[public variable]]: they are both accessible from other places in the code than the [[process]]/[[function]] itself. However, unlike a public variable, when a local variable is declared, ''all'' following processes will have that local. | A local variable is a [[variable]] that is specific to a [[process]] in the same way as a [[public variable]]: they are both accessible from other places in the code than the [[process]]/[[function]] itself. However, unlike a public variable, when a local variable is declared, ''all'' following processes will have that local. | ||
- | Note that in | + | Note that in earlier versions of [[Fenix]] (Fenix [[0.84b]] and before) the first local variable to be defined is bugged and will cause the program to crash if used. To avoid this, the first local to be declared by the user should not be used, but instead be a garbage variable. |
- | There's also a number of [[predefined]] local variables, | + | There's also a number of [[predefined]] [[local variables]]. |
+ | |||
+ | To start the declaration of local variables, use [[Local]]. | ||
== Example == | == Example == | ||
<pre> | <pre> | ||
- | Program example; | ||
- | Const | ||
- | someconstantvariable; | ||
- | Global | ||
- | int globalint; | ||
- | string globalstring; | ||
- | //etc... | ||
Local | Local | ||
- | | + | // For versions 0.84b and before declare a garbage variable here |
- | // | + | // insert local variables that you can use here |
+ | End | ||
+ | |||
+ | Process Main() | ||
Begin | Begin | ||
//rest of program... | //rest of program... | ||
End | End | ||
+ | </pre> | ||
+ | Used in example: [[Process]], [[Local]], [[Begin]], [[End]] |
Current revision
[edit] Definition
A local variable is a variable that is specific to a process in the same way as a public variable: they are both accessible from other places in the code than the process/function itself. However, unlike a public variable, when a local variable is declared, all following processes will have that local.
Note that in earlier versions of Fenix (Fenix 0.84b and before) the first local variable to be defined is bugged and will cause the program to crash if used. To avoid this, the first local to be declared by the user should not be used, but instead be a garbage variable.
There's also a number of predefined local variables.
To start the declaration of local variables, use Local.
[edit] Example
Local // For versions 0.84b and before declare a garbage variable here // insert local variables that you can use here End Process Main() Begin //rest of program... End