#DEFINE label substitution
#DEFINE label(param1,param2...) substitution
The #define directive can be used in two ways -
1) To define a label to use in a #ifdef or #ifndef statements.
2) To define a single line substitution for use within the program.
Do not confuse the use of '#define' and 'symbol ='. '#define' is a directive and, when used with #ifdef, determines which sections of code are going to be compiled. ‘symbol = ’ is a command used within actual programs to re-label variables and pins.
When using a #define to specify a substitution take care to not inadvertently include an "=" before the substitution if it is not required as it will be taken as part of the substitution; this may cause unexpected syntax errors when the substition is used, for example -
#define SIZE = 20 ; Most likely incorrect
let w0 = SIZE
When expanded this will substitute as "let w0 = = 20" which is incorrect and will generate a syntax error. The correct substitution should be without the "=" symbol -
#define SIZE 20 ; Most likely correct. No "=" symbol
let w0 = SIZE
The #define substitution can be any arbitrary text; a number, variable name, command or more complicated substitution.
The substitution can have parameters which allow values to be passed into the substitution. For example the following will create an expansion which can be used to report the progress of executing code which may be useful in debugging -
#define AT(where) sertxd( "now executing - ", where, cr, lf )
AT( "main" )
b0 = b0 + 1
AT( "mysub" )
Note that #define only allows a substitution to be defined on a single line. To use multi-line substitutions use the #macro command