This is the documentation page for Module:Sandbox/Squc/Roman

This module converts Roman numerals to decimal form, and rejects invalid ones. It can be used normally, or through another module. This is still under construction, check back in a few days!

This module is intended to run through a template, which is still under construction.

To convert Roman numerals to decimal form, use Template:Mlx, which outputs 2013. If the Roman numeral is invalid, it will throw an error. If JavaScript is enabled, you can click the Script error link, and the first sentence should show the cause of the error. The final value will still be given in brackets after the error messages.

To force no errors, use Template:Mlx.

To output errors directly into the text, use Template:Mlx.

To use this through another module, use something like this:

local roman = require( "Module:Sandbox/Squc/Roman" )

local romannum = "MMXIII"
local value = roman.todecimald( romannum )


Error demonstration
function No errors Warnings Invalid Errors
Example MMXIII XXXXX XCC ABC
todecimal 2013 50 Roman numeral usage errors: More than four X in a row, suggestion: L? - roman numeral 5, char 5 190 Roman numeral usage errors: Repeat after subtraction - XCC - roman numeral 3, char 3 100 Syntax errors: Unknown character "A" found - char 1; Unknown character "B" found - char 2
todecimal|mode=1 2013 50 190 100
todecimal|mode=2|disp=Decimal ... Decimal number: 2013, Errors , Time 0.11026 Decimal number: 50, Errors Roman numeral usage errors: More than four X in a row, suggestion: L? - roman numeral 5, char 5, Time 0.11372 Decimal number: 190, Errors Roman numeral usage errors: Repeat after subtraction - XCC - roman numeral 3, char 3, Time 0.11722 Decimal number: 100, Errors Syntax errors: Unknown character "A" found - char 1; Unknown character "B" found - char 2, Time 0.12114
todecimald Intended for use only from other modules. See below for more details.

Errors will be combined, e.g. "XXXXXXCC" gives:

Decimal number: 140, Errors Roman numeral usage errors: More than four X in a row, suggestion: L? - roman numeral 5, char 5; More than four X in a row, suggestion: L? - roman numeral 6, char 6; Number of X before X must be at most two - roman numeral 7, char 7; Repeat after subtraction - XCC - roman numeral 8, char 8, Time 0.12644

or with mode=2|disp=0 (default):

[num]140 [err]Roman numeral usage errors: More than four X in a row, suggestion: L? - roman numeral 5, char 5; More than four X in a row, suggestion: L? - roman numeral 6, char 6; Number of X before X must be at most two - roman numeral 7, char 7; Repeat after subtraction - XCC - roman numeral 8, char 8 [time]0.13086

todecimald

The function todecimald (direct) is only intended for use in other modules. The output will be in the form (comma-separated list): Decimal, Error message, Time taken

The decimal will be a number, it will be the converted number if there are no errors or if it is a warning (it is invalid but still can be converted), it will be -1 if there is an error (cannot be converted). The error message is a string and will always exist, it will be "" if no error is found.