User manual

ASURO - 59
-
C for ASURO
9.1.3. Compiler directives
You may have wondered about the  rst program line #include “asuro.h”. This #include-directive
de nes an inclusion of an external source code into your program and orders the compiler to
include the text le in the compiler sequence. Our include- le contains some functions, which will
be needed for robot operations.
Another important directive (amongst others, which are lying beyond the scope of our introduction
to C) is the so called text replacement. This directive will be de ned by a pattern:
#de ne NAME replacement_text
and wil be used to de ne constants in our programs.
Wherever the symbol NAME is found in the source text, it will be replaced automatically by
replacement_text. For the NAME following #de ne the same naming conventions as for variables
have to be applied. C-programmers are used to writing the symbols (eg. NAME) at the #de ne in
capital letters.
Example:
#include “asuro.h”
#de ne STARTINGVALUE 33
int main(void) {
int i;
i= STARTINGVALUE; // the value for i is now 33
return 0;
}
Remark: Compiler directives are not closed by a semicolon!
9.1.4. Conditions
Sometimes we would like to execute commands under certain conditions. These conditional
sequences are called control structures. The simplest of these control structures is an “if-else”
sequence.
In “C” the correct syntax will be as follows:
if (Condition)
Command_block_1
else
Command_block_2
The program will check the value of the condition between the brackets. If the condition is true
(which implies any value except zero), the program will execute Command_block_1 and otherwise
the optional Command_block_2.