Lasso Soft Inc. > Home

[lp_color_random]

Linklp_color_random
AuthorKen Wallace
CategoryUtility
Version8.5.x
LicensePublic Domain
Posted03 Oct 2007
Updated03 Oct 2007
More by this author...

Description

Returns a random 6 digit hexadecimal string from a 96 alphanumeric character set 0-9, A-F, to generate random colors from 16.7 milliom possible combinations.

Sample Usage

bgcolor="#[lp_color_random]"

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.

[
/*----------------------------------------------------------------------------

[lp_color_random]
Returns a random 6 digit hexadecimal string.

Author: Ken Wallace, www.sealevel.ca
Last Modified: August 15, 2007
License: Public Domain

Description:
Returns a random 6 digit hexadecimal string from a 96 alphanumeric character set 0-9, A-F, to generate random colors from 16.7 milliom possible combinations.

Sample Usage:
bgcolor="#[lp_color_random]"


----------------------------------------------------------------------------*/
		
]

[

define_tag:'lp_color_random',
	-description='Returns a random 6 digit hexadecimal string.',
	-priority='replace',
	-optional='length';

	// based on a tag by Bil Corry based on a tag by Greg Willits

	local:'alphanumeric' = '000000111111222222333333444444555555666666777777888888999999AAAAAABBBBBBCCCCCCDDDDDDEEEEEEFFFFFF';

	if: !(local_defined:'length');
		local:'length' = 6;
	/if;

	local:'lp_color_random' = string;
	loop:(integer:#length);
		#lp_color_random += #alphanumeric->(get:(integer:(math_random: -lower=1, -upper=96)));
	/loop;
	return: #lp_color_random;

/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