'
' Convert Decimal Number to Roman Number
'   http://en.wikipedia.org/wiki/Roman_numerals
'
' December MMIX, PvE - GPL.
' Revised September MMXIII - PvE - requires BaCon 2.3 or higher.
'
'-----------------------------------------------------------------------------

SPLIT ARGUMENT$ BY " " TO arg$ SIZE dim

IF dim < 2 THEN
    PRINT "Usage: roman <value>"
    END
END IF

num = VAL(arg$[1])

GLOBAL value[13]
GLOBAL roman$[13]

FOR i = 0 TO 12
    READ roman$[i], value[i]
NEXT i
DATA "M", 1000, "CM", 900, "D", 500, "CD", 400, "C", 100, "XC", 90, "L", 50, "XL", 40, "X", 10, "IX", 9, "V", 5, "IV", 4, "I", 1

FOR i = 0 TO 12
    WHILE num >= value[i] DO
        result$ = result$ & roman$[i]
        DECR num, value[i]
    WEND
NEXT

PRINT result$