Lasso Soft Inc. > Home

[lp_math_DMStoDeg]

Linklp_math_DMStoDeg
AuthorBil Corry
CategoryMath
Version8.x
LicensePublic Domain
Posted20 Apr 2006
Updated20 Apr 2006
More by this author...

Description

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

Requires [lp_decimal_precisionset]

Sample Usage

(lp_math_DMStoDeg:'180:30:30');

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_DMStoDeg',
	-description='Returns degrees given an angle in Degrees: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 degrees, minutes, seconds
	local:'d' = 0;
	local:'m' = 0;	
	local:'s' = 0;
	if: #deg->size == 1;	
		#d = (decimal: #deg->(get:1));
	else: #deg->size == 2;
		#d = (decimal: #deg->(get:1));
		#m = (decimal: #deg->(get:2));
	else: #deg->size == 3;	
		#d = (decimal: #deg->(get:1));
		#m = (decimal: #deg->(get:2));
		#s = (decimal: #deg->(get:3));
	/if;

	// return answer
	return: (lp_decimal_precisionset: #d + (#m / 60.0) + (#s / 3600.0), (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