CESCH Posted July 5, 2012 Share Posted July 5, 2012 is there a way to do cases in scar kinda like how they have it in java if any one is confused a case statement is kinda like an advanced if else Quote Link to comment Share on other sites More sharing options...
sjesper Posted July 5, 2012 Share Posted July 5, 2012 [sCAR] case random(2) of 0: writeln('0'); 1: writeln('1'); end;[/sCAR] And if you would like some more code in the cases then just 1 line then do it like this: [sCAR]case random(2) of 0: begin writeln('0'); writeln('Hi'); end; 1: begin writeln('1'); writeln('lala'); end; end;[/sCAR] Quote Link to comment Share on other sites More sharing options...
FHannes Posted July 5, 2012 Share Posted July 5, 2012 Note that unlike Java, break statements aren't used in Pascal case statements, a Java switch can remove the breaks to jump into a next case, this isn't possible with Pascal case statements. You can however evaluate multiple values with the same case. [scar]case X of 1..8: begin end; // This is a value range 10, 11: begin end; // This are 2 separate values 9, 12..15: begin end; // They can also be combined else begin end; // Default end;[/scar] http://wiki.scar-divi.com/index.php?title=The_Official_SCAR_Scripting_Guide#Case_Statements Quote Link to comment Share on other sites More sharing options...