While the SELECT/SELECTONE statements can be used similar to the
CASE statement. For example,
SELECT expression OF
1: WRITELN('ONE');
2: WRITELN('TWO');
OTHERWISE WRITELN('not ONE or TWO')
END
a more subtle (and powerful) form uses the Boolean constant
'TRUE' as the select-selector. For example,
SELECTONE True OF
expression < 10: WRITELN('Value is small');
expression < 100: WRITELN('Value is medium');
expression < 1000: WRITELN('Value is big');
OTHERWISE WRITELN('Value is too big');
END
SELECTONE True OF
expression = "AAA": writeln('String is AAA');
expression = "BBB": writeln('String is BBB');
expression = "CCC": writeln('String is CCC');
OTHERWISE writeln('unknown string');
END
FOR i := 1 TO 10 DO
SELECT True OF
ODD(i): WRITELN('value ',i:1,' is odd');
(i MOD 3) = 0:
WRITELN('value ',i:1,' is also a multiple of 3');
END;