function RomanToDec4(Roman: String): LongInt;
const
Arabics: Array[1..16] of Integer = (1000000, 100000, 10000, 1000, 900, 500, 400, 100, 90, 50, 40,
10, 9, 5, 4, 1);
Romans: Array[1..16] of String = ('{M}', '[M]', '(M)', 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L',
'XL', 'X', 'IX', 'V', 'IV', 'I');
var
iFor, iLen: Integer;
sTemp: String;
begin
Result := 0;
for iFor := 1 to 16 do
begin
iLen := Length(Romans[iFor]);
sTemp := Copy(Roman, 1, iLen);
while ((Length(Roman) > 0) and (sTemp = Romans[iFor])) do
begin
Roman := Copy(Roman, 1 +iLen, Length(Roman) -1);
Result := Result +Arabics[iFor];
sTemp := Copy(Roman, 1, iLen);
end;
end;
end;