Lasso Soft Inc. > Home

[lp_math_HMStoDeg]

Linklp_math_HMStoDeg
AuthorBil Corry
CategoryMath
Version8.x
LicensePublic Domain
Posted21 Apr 2006
Updated21 Apr 2006
More by this author...

Description

Returns degrees given an angle in Hours:Minutes:Seconds.

Requires [lp_decimal_precisionset]

Sample Usage

(lp_math_HMStoDeg:'23:59:59');

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.

[

define_tag:'lp_math_HMStoDeg',
	-description='Returns degrees given an angle in Hours:Minutes:Seconds.',
	-priority='replace',
	-required='degrees',
	-optional='precision';
	
	if: !(local_defined:'precision');
		local:'precision' = 6;
	/if;

	// replace the delimiters with ours
	local:'deg' = (string_replaceregexp: (string:#degrees), -find='[^0-9]',-replace=' ');
	#deg = (string_replaceregexp: #deg, -find=' +',-replace=' ');
	#deg->trim;
	#deg = #deg->(split:' ');


	// get hours, minutes, seconds
	local:'h' = 0;
	local:'m' = 0;	
	local:'s' = 0;
	if: #deg->size == 1;	
		#h = (decimal: #deg->(get:1));
	else: #deg->size == 2;
		#h = (decimal: #deg->(get:1));
		#m = (decimal: #deg->(get:2));
	else: #deg->size == 3;	
		#h = (decimal: #deg->(get:1));
		#m = (decimal: #deg->(get:2));
		#s = (decimal: #deg->(get:3));
	/if;

	// return answer
	return: (lp_decimal_precisionset: (#h * 15.0) + (#m * 0.25) + (#s * 0.0041666666666666666666666666666667), (integer:#precision));

/define_tag;

]

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