Az alábbi függvény a megadott arab számot római számmá alakítja: function TfrmMain.IntToRome(Number:integer): string; var R1, R2, R3: char; S: string[4]; I: integer; begin if (Number > 0) and (Number < 4000) then begin Result := ''; S := IntToStr(Number); while length(S) < 4 do S := '0'+S; I := 1; R1 := '*'; R2 := '*'; R3 := '*'; while I <= length(S) do begin if I = 1 then begin R1 := 'M'; R2 := '*'; R3 := '*'; end; if I = 2 then begin R1 := 'C'; R2 := 'D'; R3 := 'M'; end; if I = 3 then begin R1 := 'X'; R2 := 'L'; R3 := 'C'; end; if I = 4 then begin R1 := 'I'; R2 := 'V'; R3 := 'X'; end; case StrToInt(S[I]) of 1 : Result := Result+R1; 2 : Result := Result+R1+R1; 3 : Result := Result+R1+R1+R1; 4 : Result := Result+R1+R2; 5 : Result := Result+R2; 6 : Result := Result+R2+R1; 7 : Result := Result+R2+R1+R1; 8 : Result := Result+R2+R1+R1+R1; 9 : Result := Result+R1+R3; end; inc(I); end; end else Result := ''; end;