This example declares a subtype for roman numbers
$ include "seed7_05.s7i";
include "wrinum.s7i";
const type: romanNum is subtype integer;
const func string: str (in romanNum: number) is
return str(ROMAN, number);
enable_output(romanNum);
const proc: main is func
local
var romanNum: number is 0;
begin
for number range 1 to 3999 do
writeln(number);
end for;
end func;
The subtype romanNum can be used everywhere an integer can be used.
The 'str' function declared for romanNum cannot be used by integers.
The template enable_output uses the 'str' function of romanNum to define
write, writeln, etc. for romanNum.
Therefore romanNums are written as roman numbers while integers are written in the usual Arabic numeral system.
To write an integer directly as roman number use 'write(str(ROMAN, number))'.