
SimplIQ Software Manual 4BThe SimplIQ User Programming Language
MAN-SIMSW (Ver. 1.4)
5-2
In addition to the Interpreter commands, a program may include program flow statements
that manage how the program runs:
Iterations, such as:
for I=1:10:100
Subroutine execution commands, such as:
If(I>=100)
Conditions, such as:
while(I<1000)
In the program text, semicolons, commands, line feeds or carriage returns separate the
commands, as in the following examples:
int x,k;
Variable declarations
##Func
Label definition
x=0;
Initialize
for k=0:10
Iterate
x = x + 1 ;
Do something
End
End of iteration
Exit
End of program directive
##Lab
… More code
The program defines two variables named x and k.
##Func
is an entry point. After
compilation, this piece of code can be run by sending the command
XQ##Func
to the
Interpreter.
When the program starts at
##Func
, it clears the user variable x. This is not performed
automatically and an initial value must be set manually for every relevant variable. The
program then iterates 11 times, incrementing x with every iteration. Finally, x = 11.
The Exit command terminates program execution. Another code section can then be
executed by sending the command
XQ##Lab
.
Example:
switch (IP & 3)
Select according to the two low input bits.
case 1
The numerical interpretation of
(IP&3)
is 1.
PR=1000;
case 2
The numerical interpretation of
(IP&3)
is 2.
PR=500;
If value is two . . .
otherwise
PR=100;
Otherwise . . . (last two bits are 0 or 3).
end
BG
Begin motion.
This example moves an axis with a step that depends on the state of the digital inputs.
Kommentare zu diesen Handbüchern