User manual
ASURO - 62
-
9. C für ASURO
“while(1)” is equivalent to “for(;;)”, and both are eternal loops as the abort condition (in this case a
value 0) will never be reached.
Another loop sequence is a “do”-loop
do
command block
while( condition);
In contrast to a “while”-loop the condition will be checked after the command block. This
programming sequence forces the command block to be executed at least one time.
9.1.6. Functions
A de nition block for a function always looks like:
Functions type Functions Name (ParameterType1 ParameterName1,
ParameterType2 ParameterName2, ...)
Really great, de nition blocks for a function! Why so complicated???
Well, they are very useful, but their explanation is rather complex and may be postponed...
Sometimes we need to use the same programming sequences at different locations in our
programs. Of course we might repeat the writing or use a copy/paste-method for this purpose (this
is an annoying procedure and turns our program into a mess) or we just de ne a funtion.
Now sometimes we need to pass a few variables to a function, eg. telling our GoAhead () -function
to use a given speed exactly, a certain lapse of time or a de ned distance. We will use parameters
for these details.
Sometimes a function will even return a value. A good example is the
HowManySwitchesHaveBe
enActivated () -Function, returning a value, which will be de ned somehow and somewhere within
the function-block. The value is returned by a return-command at the end of the function-body.
That’s why functions end with
return; or return number;.
A special function is the
main () -function, de ning the main body of a program. In ASURO the
main () -function will be executed at switching ON. Of course every program must be supplied
with a main () -function.