DECLARE SUB roman (a%, I%)

'

DIM SHARED b$

b$ = "IVXLCDM"

DO

DO

INPUT "Enter an integer >0 and <4000 (0 to exit)"; a%

IF a% < 1 THEN END

LOOP UNTIL a% < 4000

PRINT

roman a%, 1

PRINT

LOOP

END

SUB roman (a%, I%)

IF a% = 0 THEN EXIT SUB

n% = a% MOD 10

roman a% \ 10, I% + 2

SELECT CASE n%

CASE 9:

PRINT MID$(b$, I%, 1) + MID$(b$, I% + 2, 1);

CASE 8, 7, 6:

PRINT MID$(b$, I% + 1, 1) + STRING$(n% - 5, ASC(MID$(b$, I%, 1)));

CASE 5:

PRINT MID$(b$, I% + 1, 1);

CASE 4:

PRINT MID$(b$, I%, 1) + MID$(b$, I% + 1, 1);

CASE 3, 2, 1:

PRINT STRING$(n%, ASC(MID$(b$, I%, 1)));

END SELECT

END SUB