Module RomanNumbers { flush ' empty current stack gosub Initialize document Doc$ while not empty read rom$ print rom$;"=";RomanEval$(rom$) Doc$=rom$+"="+RomanEval$(rom$)+{ } end while Clipboard Doc$ end Initialize: function RomanEval$(rom$) { Flush ="invalid" if filter$(rom$,"MDCLXVI")<>"" Then Exit \\ "Y" is in top of stack Push "CM", "MD", "Q" Push "CD", "MD","W" Push "XC", "DL", "E" Push "XL", "X","R" Push "IX","V","T" Push "IV","I","Y" \\ stack flush to doublerom doublerom=[] \\ "M" is in top of stack Data "M", 1000, "Q",900 Data "D", 500,"W", 400 Data "C",100,"E",90 Data "L",50,"R", 40 Data "X", 10, "T", 9 Data "V", 5, "Y", 4, "I",1 \\ stack flush to singlerom singlerom=[] acc=0 value=0 count=0 stack doublerom { if empty then exit read rep$,exclude$,cc$ i=instr(rom$,cc$) if i >0 then tmp$=mid$(rom$,i+2) L=Len(tmp$) if L>0 then if Len(filter$(tmp$, exclude$))<>L then rom$="A": exit if Instr(rom$,mid$(rom$,i,1))3 then exit loop } if len(rom$)>0 or count>3 Else =Str$(acc,1033) end if } data "MMMCMXCIX", "LXXIIX", "MMXVII", "LXXIX", "CXCIX","MCMXCIX","MMMDCCCLXXXVIII" data "CMXI","M","MCDXLIV","CCCC","IXV", "XLIXL","LXXIIX","IVM" data "XXXIX", "XXXX", "XIXX","IVI", "XLIX","XCIX","XCIV","XLVIII" return } RomanNumbers