- This wiki is out of date, use the continuation of this wiki instead
Declare
From FenixWiki
Revision as of 00:52, 13 May 2007 (edit) Sandman (Talk | contribs) m ← Previous diff |
Current revision (18:22, 5 December 2007) (edit) (undo) Sandman (Talk | contribs) m |
||
(9 intermediate revisions not shown.) | |||
Line 1: | Line 1: | ||
+ | [[Category:reserved]] | ||
[[Category:language]] | [[Category:language]] | ||
+ | [[Category:Basic statement]] | ||
== Definition == | == Definition == | ||
- | '''Declare''' [Function|Process] [<returntype>] <name>([<parameters>]) | + | '''Declare''' [Function|Process] [<returntype>] <name>([<parameters>])<br> |
+ | :['''Private'''<br> | ||
+ | :<private variables><br> | ||
+ | :'''End''']<br> | ||
+ | :['''Public'''<br> | ||
+ | :<public variables><br> | ||
+ | :'''End''']<br> | ||
+ | '''End'''<br> | ||
+ | Declare is a reserved word used to declare a [[process]] or [[function]] before its actual code. This can be useful if the function or process needs to be known before it is actually defined, like when the function returns something other than an [[int]] or when the [[publics]] of the process need to be accessed before the definition. By default, the returntype of a process or function is an [[int]]. | ||
- | + | When using this statement, a few things can be defined about the process/function: | |
+ | * If it's a process or function | ||
+ | * Its returntype | ||
+ | * The parameters of the process or function | ||
+ | * The public variables of the process or function | ||
+ | * The private variables of the process or function | ||
+ | The first three are defined when using the statement Declare, while the last two are defined within the Declare block. | ||
+ | |||
+ | == Notes == | ||
Note that this functionality is only available in [[Fenix]] [[0.89]] and up. Also before version [[0.93]], defining the returntype as an int, the compiler would nag. This is worked around by removing the int statement. | Note that this functionality is only available in [[Fenix]] [[0.89]] and up. Also before version [[0.93]], defining the returntype as an int, the compiler would nag. This is worked around by removing the int statement. | ||
+ | |||
+ | When the Declare statement is used for a [[function]]/[[process]] and the process has [[public variable]]s, they need to be declared in the Declare block. Else the compiler will nag it expected BEGIN. | ||
== Example == | == Example == |
Current revision
[edit] Definition
Declare [Function|Process] [<returntype>] <name>([<parameters>])
- [Private
- <private variables>
- End]
- [Public
- <public variables>
- End]
End
Declare is a reserved word used to declare a process or function before its actual code. This can be useful if the function or process needs to be known before it is actually defined, like when the function returns something other than an int or when the publics of the process need to be accessed before the definition. By default, the returntype of a process or function is an int.
When using this statement, a few things can be defined about the process/function:
- If it's a process or function
- Its returntype
- The parameters of the process or function
- The public variables of the process or function
- The private variables of the process or function
The first three are defined when using the statement Declare, while the last two are defined within the Declare block.
[edit] Notes
Note that this functionality is only available in Fenix 0.89 and up. Also before version 0.93, defining the returntype as an int, the compiler would nag. This is worked around by removing the int statement.
When the Declare statement is used for a function/process and the process has public variables, they need to be declared in the Declare block. Else the compiler will nag it expected BEGIN.
[edit] Example
Declare Process example_process() Public // Declare public variables for the process example_process int public_int; string public_string; End // This End is optional Private // Declare private variables for the process example_process int private_int; End End Declare Function string example_function( int param_int) Private // Declare private variables for the process example_process int private_int; End End Process example_process(); /* The Declare handles this section. Public int public_int; string public_string; Private int private_int; */ Begin Loop frame; End End Function string example_function( int param_int) Begin return ""; End