program ideone;
function GetError(a, b, c, d: string): string;
begin
GetError := a;
if ((GetError <> '') and (GetError <> '0')) then
GetError := b
else
begin
GetError := c;
if ((GetError <> '') and (GetError <> '0')) then
GetError := d;
end;
if (GetError = '0') then
GetError := '';
end;
begin
writeln('Without error');
// Last_OI_Errno,Last_IO_Error, Last_SQL_Errno, Last_SQL_Error
writeln('Start 1 -> ' + GetError('', '', '', ''));
writeln('Start 2 -> ' + GetError('0', '', '', ''));
writeln('Start 3 -> ' + GetError('', 'Error1', '', ''));
writeln('Start 4 -> ' + GetError('', '', '0', ''));
writeln('Start 5 -> ' + GetError('', '', '', 'Error2'));
writeln('With error');
writeln('Start 1 -> ' + GetError('12', '', '', ''));
writeln('Start 2 -> ' + GetError('12', 'Error 12', '', ''));
writeln('Start 3 -> ' + GetError('0', '', '2', 'Error 20'));
end.
cHJvZ3JhbSBpZGVvbmU7CgoJZnVuY3Rpb24gR2V0RXJyb3IoYSwgYiwgYywgZDogc3RyaW5nKTogc3RyaW5nOwoJYmVnaW4KCQlHZXRFcnJvciA6PSBhOwoJCWlmICgoR2V0RXJyb3IgPD4gJycpIGFuZCAoR2V0RXJyb3IgPD4gJzAnKSkgdGhlbgoJCQlHZXRFcnJvciA6PSBiCgkJZWxzZQoJCWJlZ2luCgkJCUdldEVycm9yIDo9IGM7CgkJCWlmICgoR2V0RXJyb3IgPD4gJycpIGFuZCAoR2V0RXJyb3IgPD4gJzAnKSkgdGhlbgoJCQkJR2V0RXJyb3IgOj0gZDsKCQllbmQ7CgkJaWYgKEdldEVycm9yID0gJzAnKSB0aGVuCgkJCUdldEVycm9yIDo9ICcnOwoJZW5kOwoKYmVnaW4KCXdyaXRlbG4oJ1dpdGhvdXQgZXJyb3InKTsKCS8vCQkJCQkJCUxhc3RfT0lfRXJybm8sTGFzdF9JT19FcnJvciwgTGFzdF9TUUxfRXJybm8sIExhc3RfU1FMX0Vycm9yCgl3cml0ZWxuKCdTdGFydCAxIC0+ICcgKyBHZXRFcnJvcignJyw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