Difference between revisions of "Module:Leading zeros"

From blackwiki
Jump to navigation Jump to search
blackwiki>Wefk423
(Created page with 'p = {} p.stripzeros = function(frame) x = tonumber(frame.args[1]) if x then return x else return "Wrong format" end end return p')
 
blackwiki>Wefk423
(updated warning)
Line 5: Line 5:
 
return x
 
return x
 
else
 
else
return "Wrong format"
+
return "Wrong format."
 
end
 
end
 
end
 
end
 
return p
 
return p

Revision as of 23:43, 26 July 2018

This module is created for Template:SEHK. It is able to strip all leading zeros from the value (0001 to 1), while showing "Incorrect" as a error message when a non-numeric value is inputted. This module can be implemented to different template, if applicable.

Usage

{{#invoke:Leading zeros |stripzeros |"number-goes-here"}}


p = {}
p.stripzeros = function(frame)
	x = tonumber(frame.args[1])
	if x then
		return x
	else
		return "Wrong format."
	end
end
return p