Simba Code:
program new;
{$i SRL/SRL.scar}
function printa: boolean;
begin
writeln('a');
Result:= True;
end;
function printb: boolean;
begin
writeln('b');
Result:= False;
end;
function printc: boolean;
begin
writeln('c');
Result:= True;
end;
function StepFuncs(Functions: Array of String; Conditions: Array of Boolean): Boolean;
{will progress through the list of Functions with no parameters if Condition is met eg:
if this then
if that then
if thisandthat then
blahblahblah
Also, if Conditions are the same then just use it once in an array eg:
StepFuncs(['func1', 'func2', 'func3'], [True]) is the same as
StepFuncs(['func1', 'func2', 'func3'], [True, True, True])
}
var
a, b: Integer;
c: TVariantArray;
bool: boolean;
begin
b:= High(Functions);
if Length(Functions) <> Length(Conditions) then
begin
SetLength(Conditions, b + 1);
for a:= 1 to b do
Conditions[a]:= Conditions[0];
end;
for a:= 0 to b do
begin
bool:= CallProc(Functions[a], c);
if (not bool) = Conditions[a] then //<------------------here is the error!
begin
writeln('An error has occured while trying to execute:' + Functions[a]);
break;
end;
end;
end;
procedure MainLoop;
begin
StepFuncs(['printa', 'printb', 'printc'], [True, False, True]);
end;
begin
MainLoop;
end.
Seems to be working the way it is supposed to
.