Lasso Soft Inc. > Home

[pk_stringtointeger]

Linkpk_stringtointeger
AuthorPier Kuipers
CategoryString
Version8.x
LicensePublic Domain
Posted10 Jan 2006
Updated28 Jan 2007
More by this author...

Description

Tag converts a formatted number such as $100,000 back to an integer (e.g. 100000).
Note the difference with Bil's tag [lp_string_getNumeric] - my tag returns the integer value, ignoring digits after a period:
[pk_stringtointeger] $100,000.45 -> 100000 [lp_string_getNumeric] $100,000.45 -> 10000045

Sample Usage

[pk_stringtointeger:'$100,000.45']
-> 100000

[pk_stringtointeger:'+1-234 yada 23-65/01']
-> 1234236501

[pk_stringtointeger:'+1-234 yada. 23-65/01']
-> 1234

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

 split:'');
			local:'newinteger'=string;

			Iterate:#splitString, local:'x';

				If:(#x -> isdigit);
					#newinteger += #x;
				Else:(#x == '.');
					loop_abort;
				/If;

			/Iterate;

			return:(integer:#newinteger);

		/define_tag;
		
	/If;	

?>

Related Tags

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft