Open main menu

Difference between revisions of "Template:RomanPageToNegativeArabic"

(Created page with "<noinclude> Use this template to convert a roman page number into a negative arabic number, where zero iz -10000. Thus, the roman number is converted into arabic value, and th...")
 
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
<noinclude>
 
<noinclude>
Use this template to convert a roman page number into a negative arabic number, where zero iz -10000. Thus, the roman number is converted into arabic value, and the result is -10000 + value. For instance, if <code><nowiki>value=x</nowiki></code>, the template will return -9990. If <code><nowiki>value=iv</nowiki></code>, the template will return -9996. If an empty string is passed as a value, an empty string is returned. All non roman characters are ignored.
+
Use this template to convert a roman page number into a negative arabic number, where zero the roman zero is treated as -100000. Thus, the roman number is converted into arabic value, and the result is -100000 + value. For instance, if <code><nowiki>value=x</nowiki></code>, the template will return -99990. If <code><nowiki>value=iv</nowiki></code>, the template will return -99996. If an empty string is passed as a value, an empty string is returned. All non roman characters are ignored.
 +
 
 +
This is useful when storing the first page number of a publication for sorting purposes.
  
 
'''NOTE:''' As any "printing" template, it doesn't store any values anywhere, but merely prints them on the page.
 
'''NOTE:''' As any "printing" template, it doesn't store any values anywhere, but merely prints them on the page.
Line 10: Line 12:
 
-->{{#if: {{IsNumber|value={{{value|}}}|}}<!--  
 
-->{{#if: {{IsNumber|value={{{value|}}}|}}<!--  
 
   -->|<!--  
 
   -->|<!--  
   --><!-- the value is an arabic number: return it  
+
   --><!-- the value is an Arabic number: return it  
   -->{{#vardefine: varReturn|{{{value}}}|}}<!--  
+
   -->{{{value}}}<!--  
 
   --><!--  
 
   --><!--  
 
   -->|<!--  
 
   -->|<!--  
   --><!-- the value is not arabic: assume its roman and try to convert   
+
   --><!-- the value is not Arabic: assume its roman and try to convert   
   -->{{#vardefine: varNum|{{#roman: {{{value|}}}|}}|}}<!--  
+
   -->{{#expr: {{#tag:roman|{{{value|}}}|}} - 100000 }}<!--  
   -->{{#if: {{IsNumber|value={{#var:varNum}}|}}<!--
+
   --><!-- the old code: {{#expr: {{#tag:roman|{{{value|}}}|}} - 100000 }}
    -->|<!--
+
   --><!--  
    --><!-- the value is an arabic number: return -10000 + varNum
 
    -->{{#vardefine: varReturn|{{#expr: {{#var:varNum}} - 10000 }}|}}<!--
 
    --><!--
 
    -->|<!--
 
    --><!-- the value is not an arabic number: return empty string
 
    -->{{#vardefine: varReturn||}}<!--
 
    --><!--
 
   -->}}<!-- if is number 
 
  --><!-- 
 
 
-->}}<!-- if is number   
 
-->}}<!-- if is number   
--><!--
 
--><!-- return the value
 
-->{{#var: varReturn}}<!--
 
--><!--
 
 
--></includeonly>
 
--></includeonly>

Latest revision as of 22:59, 24 December 2021

Use this template to convert a roman page number into a negative arabic number, where zero the roman zero is treated as -100000. Thus, the roman number is converted into arabic value, and the result is -100000 + value. For instance, if value=x, the template will return -99990. If value=iv, the template will return -99996. If an empty string is passed as a value, an empty string is returned. All non roman characters are ignored.

This is useful when storing the first page number of a publication for sorting purposes.

NOTE: As any "printing" template, it doesn't store any values anywhere, but merely prints them on the page.

Parameters:

  • |value= - the roman page number to convert. E.g. "xiv", "lx", "mmx", etc.