Elmo HARSFEN0602, HARmonica Common, Line and Expression Termination, Line Continuation

Models: HARmonica HARSFEN0602

1 220
Download 220 pages 51.63 Kb
Page 31
Image 31

HARSFEN0602ElmoHARmonicaSoftwareManual

PRELIMINARYDRAFT

 

 

 

 

 

X=0;

Initialize

 

 

for k=0:10

Iterate

 

 

X = x + 1 ;

Do something

 

 

end

End of iteration

 

 

exit

End of program directive

 

 

##Moo

 

 

 

...

More code

 

The program defines two variables named x and k.

##Foo is an entry point.

After compilation, it is possible to run this piece of code by commanding XQ ##Foo to the interpreter.

When the program starts at ##Foo, it clears the user variable x. It then iterates 11 times, incrementing x with every iteration. Finally, x = 11.

The exit command terminates program execution.

Another code section can be executed by commanding XQ ##Moo.

Example 2:

29

switch (IP & 3)

Select according to the two low input bits

case 1

 

PR=1000;

If value is one...

case 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 in the state of the digital inputs.

5.2Common

A user program contains lines of text code. This text must have defined syntax for the Compiler to recognize it. This section contains some common description of a program text.

5.2.1Line and Expression Termination

A line has the following terminators: carriage return, line feeds or their combination.

A line can contain a single expression or sequence of expressions. Sequence of expressions in the same line can be separated with semicolon or comma (not inside round or square parentheses).

Example:

 

 

a = 3

, b = 2

, c = a

+ b , ** This line consists of three expressions separated with comma

a = 3

; b = 2 ; c = a

+ b ; ** This line consists of three expressions separated with semicolon

a = 3 , b = 2

; c = a

+ b ** This line consists of three expressions separated with comma, semicolon and

terminated with line feed

[a,b] = foo (23, c, 3.14) ** In this expression comma is not expressions separator, because it is inside parentheses

5.2.2Line Continuation

Page 31
Image 31
Elmo HARSFEN0602, HARmonica software manual Common, Line and Expression Termination, Line Continuation