Also, like C, you can jump into conditionals, although this practice isn't recommended. This is because conditionals are just shorthand for a web of labels and conditional gotos, so adding extra labels can gotos is possible.
1: #line 2249 "./lpsrc/flx_tutorial.pak" 2: #import <flx.flxh> 3: 4: inline proc f(x:int) (y:int) { 5: print "NOT ONE"; endl; 6: if x == 1 do 7: print 1; print " "; 8: if y == 20 goto twenty; 9: if y == 10 do print "TEN"; else done; 10: elif x == 2 do 11: print 2; print " "; 12: if y == 20 do 13: twenty:> 14: print "TWENTY"; 15: done; 16: else print "Dunno .. "; 17: done; 18: endl; 19: } 20: 21: f 1 10; 22: f 1 20; 23: f 1 40; 24: f 2 20; 25: f 3 30; 26:
1: #line 2281 "./lpsrc/flx_tutorial.pak" 2: #import <flx.flxh> 3: 4: proc f1(x:int) { 5: if x == 1 then { print 1; endl; } 6: else {} endif; 7: } 8: 9: proc f2(x:int) { 10: if x == 1 do print 1; endl; done; 11: } 12: 13: f1 1; 14: f2 1; 15:
Conditionals may contain declarations. However the bodies are not blocks, and the declared symbols are not local to the conditional bodies.
The macro processor can fold conditional statements, in particular it can choose between two declarations.
1: #line 2307 "./lpsrc/flx_tutorial.pak" 2: #import <flx.flxh> 3: macro val x = 1; 4: if x == 1 do val y = 1; else val y = "ONE"; done; 5: print y; endl; 6: