Programming-Idioms

History of Idiom 162 > diff from v4 to v5

Edit summary for version 5 :
New Pascal implementation by user [Bart]

Version 4

2017-08-06, 15:23:52

Version 5

2017-08-06, 16:26:46

Idiom #162 Execute procedures depending on options

execute bat if b is a program option and fox if f is a program option.

Idiom #162 Execute procedures depending on options

execute bat if b is a program option and fox if f is a program option.

Code
function HasOption(c: char): Boolean;
var
  i: integer;
begin
  Result := False;
  for i := 1 to ParamCount do
    if (ParamStr(i) = ('-' + c)) then Exit(True);
end;  

begin
  if HasOption('b') then Bat;
  if HasOption('f') then Fox;
end.
Comments bubble
The idiom does not state wether the options are exclusive.
I treated them as inclusive.