27 lines
626 B
Plaintext
27 lines
626 B
Plaintext
Nth: procedure options (main); /* 1 June 2014 */
|
|
declare i fixed (10);
|
|
|
|
do i = 0 to 25, 250 to 265, 1000 to 1025;
|
|
if i = 250 | i = 1000 then put skip (2);
|
|
put edit (enth(i)) (x(1), a);
|
|
end;
|
|
|
|
enth: procedure (i) returns (character (25) varying);
|
|
declare i fixed (10);
|
|
declare suffix character (2);
|
|
|
|
select (mod(i, 10));
|
|
when (1) suffix = 'st';
|
|
when (2) suffix = 'nd';
|
|
when (3) suffix = 'rd';
|
|
otherwise suffix = 'th';
|
|
end;
|
|
select (mod(i, 100));
|
|
when (11, 12, 13) suffix = 'th';
|
|
otherwise ;
|
|
end;
|
|
return ( trim(i) || suffix );
|
|
end enth;
|
|
|
|
end Nth;
|