1: #line 240 "./lpsrc/flx_tutorial.pak" 2: #import <flx.flxh> 3: var i = 1; 4: var j : int; 5: while {i < 10} 6: { 7: j = i + i; 8: print j; print "\n"; 9: ++i; 10: };
1: 2 2: 4 3: 6 4: 8 5: 10 6: 12 7: 14 8: 16 9: 18
You will notice the assignment in the line:
j = i + i;Naturally, variables must be initialised or assigned to before they are used, as in C.
You will also have noticed the 'while' loop, one of the control structures Felix provides: it appears to work the same way as a 'while' loop in C, except that a trailing ; is strangely required, and the condition is given in curly brackets. We'll find out exactly why later, but here is a hint: there is no while statement in Felix!