Difference between revisions of "Template:ExtractFirstPageNumber"

From Encyclopedia of Scientonomy
Jump to navigation Jump to search
Line 10: Line 10:
 
-->{{#if: {{{pages|}}}|<!--  
 
-->{{#if: {{{pages|}}}|<!--  
 
   -->{{#vardefine: varSepPos|{{#pos: {{{pages|}}}|-}}|}}<!--  
 
   -->{{#vardefine: varSepPos|{{#pos: {{{pages|}}}|-}}|}}<!--  
   -->{{#if: {{#var: varSepPos}}<!--  
+
   -->{{#ifexpr: {{#var: varSepPos}} > 0<!--  
 
   -->|<!-- separator is found: extract first page
 
   -->|<!-- separator is found: extract first page
 
     --><!--  
 
     --><!--  

Revision as of 05:21, 25 June 2017

Use this template to extract the first page number from a page-page string. For instance, if pages="23-45", the template will return 23. If pages="234", the template will return 234. If an empty string is passed as a value, an empty string is returned.

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

Parameters:

  • |pages= - pages in the "xx-yy" format. E.g. "23-145", "1-34", "vi-ix", etc.