2 Replies Latest reply on May 26, 2009 6:50 PM by comment_1

    Using calculation to convert the Roman Numeral numbers

    Otto

      Title

      Using calculation to convert the Roman Numeral numbers

      Post

       I made a search and found this script for converting roman numeral numbers to our US numbers.

      How do I create a field with this code?

       

      Roman (Text)
      Number (Calculation, Number result)
      = If (Position (Roman, "IX", 1), 9+Length (Roman)*10-20, If (Position (Roman, "IV", 1), 4+Length (Roman)*10-20, If (Right (Roman, 1) = "X", 10*Length (Roman), If (Right (Roman, 1)="V", 5+(Length (Roman)*10-10), If (Left (Roman, 3) = "XXX", 30+(Length (Roman)-3), If (Left (Roman, 2)="XX", 20+If (Position (Roman, "V", 1), 4, 0)+(Length (Roman)-2), If (Left (Roman, 1)="X", 11+If (Position (Roman, "V", 1), 4, 0)+(Length (Roman)-2), If (Left (Roman, 1)="V", 5, 1)+(Length (Roman)-1)))))))) *

        • 1. Re: Using calculation to convert the Roman Numeral numbers
          raybaudi
            

          Hi

           

          That calculation is very buggy and even with some adjustment can count only till 39.

           

          Also it was made for version till 6 and do not trap errors.

           

          If you have a more recent version ( from 7 ), you can try this one:

           

          Case(
             PatternCount ( _Roman ;    "V" ) > 1
          or PatternCount ( _Roman ;   "IX" ) > 1
          or PatternCount ( _Roman ; "XXXX" )
          or PatternCount ( _Roman ; "IIII" )
          or PatternCount ( _Roman ;  "IIV" ) 
          or PatternCount ( _Roman ;  "IIX" )
          or PatternCount ( _Roman ;  "IXX" )
          or PatternCount ( _Roman ;  "IVI" )
          or PatternCount ( _Roman ;  "IXI" )
          or PatternCount ( _Roman ;  "IXV" )
          or PatternCount ( _Roman ;   "VX" )
          ; "NOT ROMAN" ;
          Evaluate(
          Substitute ( Upper ( _Roman )
          ; [ "IX"  ; "+9"  ]
          ; [ "X"   ; "+10" ]
          ; [ "IV"  ; "+4"  ]
          ; [ "V"   ; "+5"  ]
          ; [ "I"   ; "+1"  ]
          )
          )
          )

           

           

          ( this works till 39, too )